Rank 1718
来源:互联网 发布:visual foxpro和sql 编辑:程序博客网 时间:2024/04/29 05:18
Problem 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
2AC代码
#include <cstdio>#include <algorithm>#include <vector>#include <string>#include <iostream>struct student{ std::string m_szID; int m_nScore;};class cmp{public: bool operator()(const student& lhs, const student& rhs) { return lhs.m_nScore > rhs.m_nScore; }};int main(int argc, const char* argv[]){ std::string szFind; while(std::cin >> szFind) { std::vector<student> vec; student stu; while (std::cin >> stu.m_szID >> stu.m_nScore && !(stu.m_szID == "0" && stu.m_nScore == 0)) { vec.push_back(stu); } std::sort(vec.begin(), vec.end(), cmp()); int nCount = 0, nPre = -1; for (unsigned i=0; i<vec.size(); ++i) { if (nPre == vec[i].m_nScore) { ++nCount; } else { nPre = vec[i].m_nScore; nCount = 0; } if (vec[i].m_szID == szFind) { printf("%d\n", i+1-nCount); break; } } } return 0;}
0 0
- Rank 1718
- 1718:Rank
- hdu 1718 Rank
- hdu 1718 Rank
- HDU 1718--Rank
- hdu 1718 Rank
- hdu-oj 1718 Rank
- hdoj.1718 Rank 20141019
- HDU 1718 Rank
- hdu 1718 Rank
- HDOJ 1718 Rank
- hdoj-1718-Rank
- HDU 1718 Rank
- HDU 1718 Rank
- HDU 1718 Rank
- HDOJ 1718 Rank
- Rank
- rank()
- Light OJ 1116 Ekka Dokka(数学,二进制的应用)
- myeclipse2014下载地址
- jquery让返回的内容显示在特定div里
- C# 复制,删除文件
- MyEclipse弹出提示窗口
- Rank 1718
- ubuntu 复制文件或目录 命令
- Matlab图像类型
- ReactiveCocoa与Functional Reactive Programming
- Spring3.0.5+Mybatis3.0.5+Struts2.0.6整合
- HashMap之equals与hashCode小陷阱
- 深入Java单例模式
- 关于商享网
- 内核怎样管理你的内存