CodeForces-551A GukiZ and Contest
2015-08-21 21:38
363 查看
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 2000 + 5; struct STUDENT { int score; int num; int position; bool operator < (const STUDENT Next) const { return num < Next.num; } } student[maxn]; int n; bool cmp(STUDENT Now, STUDENT Next) { return Now.score > Next.score; } int main() { while(~scanf("%d", & n)) { for(int i = 1; i <= n; i ++) { scanf("%d", &student[i].score); student[i].num = i; } sort(student + 1, student + 1 + n, cmp); student[1].position = 1; for(int i = 2; i <= n; i ++) { if(student[i].score == student[i - 1].score) student[i].position = student[i - 1].position; else student[i].position = i; } sort(student + 1, student + 1 + n); for(int i = 1; i < n; i ++) printf("%d ", student[i].position); printf("%d\n",student .position); } return 0; }
题意:
自己都没怎么仔细看。意会了下。输入n。之后输入n个数。之后按顺序输出比这个数 大的数 的个数(+1)。
例如 3 5 3 4 5。比3大的数有3个,则输出3 + 1 = 4。比5大的数有0个,则输出0 + 1 = 1。
题解:
我写麻烦了。
相关文章推荐
- 记录glibc编译失败经历
- JAVA反射机制
- Gift Hunting(分组背包)
- HDOJ--1248--寒冰王座
- 组合——Program B
- Android问题:设置了requestWindowfeature(window.feature_no_title)后,为什么还要getwindow.setFlags?
- Gift Hunting(分组背包)
- 五大常用算法之三:贪心算法
- appium-webview应用的测试
- Romantic( 线性方程)
- Java 泛型 详解
- 魔术方法
- 读书笔记:Objective-C高级编程 iOS与OS X多线程和内存管理 ——(持续)
- python环境安装paramiko模块
- 二维数组的练习----求和
- PAT 1045. Favorite Color Stripe (30)
- 【leetcode】Isomorphic Strings【java】
- 五大常用算法之二:动态规划算法
- Python学习笔记1(小甲鱼)—— 安装Python3
- 洛谷1093 奖学金 解题报告