HDOJ(HDU) 1718 Rank(水题、、、)

简介: HDOJ(HDU) 1718 Rank(水题、、、)

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

20070101

20070102 100

20070101 33

20070103 22

20070106 33

0 0


Sample Output

2


其实就是统计按成绩排名,第一个输入的是学号,这个学号对应的成绩可以排第几!!!

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc  =new Scanner(System.in);
        while(sc.hasNext()){
            long[] a = new long[1005];
            long[] b = new long[1005];
            long n = sc.nextLong();
            int k=0;
            int num=0;
            for(int i=0;;i++){
                a[i]=sc.nextLong();
                b[i]=sc.nextLong();
                if(a[i]==0){
                    num=i;
                    break;
                }
                if(a[i]==n){
                    k=i;
                }
            }
            int tm=1;
            for(int i=0;i<num;i++){
                //System.out.println(a[i]);
                if(b[i]>b[k]){
                    tm++;
                }
            }
            System.out.println(tm);
        }
    }
}
目录
相关文章
HDU-1009,FatMouse' Trade(贪心水题)
HDU-1009,FatMouse' Trade(贪心水题)
HDOJ(HDU) 2304 Electrical Outlets(求和、、)
HDOJ(HDU) 2304 Electrical Outlets(求和、、)
87 0
HDOJ/HDU 2560 Buildings(嗯~水题)
HDOJ/HDU 2560 Buildings(嗯~水题)
96 0
HDOJ/HDU 2560 Buildings(嗯~水题)
HDOJ(HDU) 2107 Founding of HDU(找最大值)
HDOJ(HDU) 2107 Founding of HDU(找最大值)
71 0
|
机器学习/深度学习 人工智能 BI
HDOJ/HDU 2550 百步穿杨(注意排序)
HDOJ/HDU 2550 百步穿杨(注意排序)
87 0
HDOJ/HDU 2551 竹青遍野(打表~)
HDOJ/HDU 2551 竹青遍野(打表~)
87 0
|
算法 C++
HDOJ(HDU) 2109 Fighting for HDU(简单排序比较)
HDOJ(HDU) 2109 Fighting for HDU(简单排序比较)
89 0
HDOJ(HDU) 2503 a/b + c/d(最大公约数问题)
HDOJ(HDU) 2503 a/b + c/d(最大公约数问题)
111 0
HDOJ(HDU) 1406 完数
HDOJ(HDU) 1406 完数
81 0
|
算法
HDOJ/HDU 1015 Safecracker(深搜)
HDOJ/HDU 1015 Safecracker(深搜)
77 0