Rank
来源:互联网 发布:哈尔滨淘宝培训 编辑:程序博客网 时间:2024/06/11 00:30
Rank
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4818 Accepted Submission(s): 1364Problem Description
Jackson wants to know his rank in the class. The professor has posted a list of student numbers and marks. Compute Jackson’s rank in class; that is, if he has the top mark(or is tied for the top mark) his rank is 1; if he has the second best mark(or is tied) his rank is 2, and so on.
Input
The input consist of several test cases. Each case begins with the student number of Jackson, an integer between 10000000 and 99999999. Following the student number are several lines, each containing a student number between 10000000 and 99999999 and a mark between 0 and 100. A line with a student number and mark of 0 terminates each test case. There are no more than 1000 students in the class, and each has a unique student number.
Output
For each test case, output a line giving Jackson’s rank in the class.
Sample Input
2007010120070102 10020070101 3320070103 2220070106 330 0
Sample Output
2
#include <iostream>#include <vector>#include <algorithm>#include <stdio.h>using namespace std;struct Node{ int number; int grade; Node(){ number = 0; grade = 0; }};int n;bool cmp(Node a,Node b){ return a.grade > b.grade;}int main(){ while (cin >> n) { int a,b; vector<Node> v1; int score; while( scanf("%d",&a) && scanf("%d",&b) ){ if (a == 0 && b == 0) break; Node node; node.number = a; node.grade = b; if (a == n) { score = b; } v1.push_back(node); } sort(v1.begin(),v1.end(),cmp); for(int i=0;i<v1.size();i++){ if(v1[i].grade==score){ cout<<i+1;break; } } cout<<endl; } return 0;}
0 0
- Rank
- rank()
- rank
- RANK
- Rank
- rank
- Rank
- Rank
- Rank
- rank
- rank函数
- Trust Rank
- rank over()
- Rank List
- proc rank
- rank函数
- hdu1718 Rank
- Rank (MDX)
- 架构对比
- 第二小整数
- CentOS下MySQL的彻底卸载
- 开门人和关门人
- 排名
- Rank
- Docker#docker dead but pid file exists
- decimal system
- Box of Bricks
- 各大公司Java后端开发面试题总结
- ubantu安装mysql
- oracle 恢复delete数据
- 最小公倍数
- 语法分析