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);
        }
    }
}
目录
相关文章
hdoj 1078 FatMouse and Cheese(记忆化搜索)
简单的记忆化搜索,和其他不一样的地方就是这个一次可以走K步,其他没啥!!
48 0
HDOJ 1056 HangOver(水题)
HDOJ 1056 HangOver(水题)
100 0
HDOJ 1056 HangOver(水题)
HDOJ 1081(ZOJ 1074) To The Max(动态规划)
HDOJ 1081(ZOJ 1074) To The Max(动态规划)
81 0
HDOJ 1081(ZOJ 1074) To The Max(动态规划)
|
机器学习/深度学习 人工智能 BI
HDOJ/HDU 2550 百步穿杨(注意排序)
HDOJ/HDU 2550 百步穿杨(注意排序)
106 0
HDOJ(HDU) 2148 Score(比较、)
HDOJ(HDU) 2148 Score(比较、)
103 0
HDOJ(HDU) 2304 Electrical Outlets(求和、、)
HDOJ(HDU) 2304 Electrical Outlets(求和、、)
107 0
HDOJ(HDU) 2161 Primes(素数打表)
HDOJ(HDU) 2161 Primes(素数打表)
112 0
HDOJ(HDU) 2107 Founding of HDU(找最大值)
HDOJ(HDU) 2107 Founding of HDU(找最大值)
111 0
HDOJ(HDU) 2061 Treasure the new start, freshmen!(水题、)
HDOJ(HDU) 2061 Treasure the new start, freshmen!(水题、)
135 0
HDOJ(HDU) 1555 How many days?(水题)
HDOJ(HDU) 1555 How many days?(水题)
96 0