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);
        }
    }
}
目录
相关文章
|
Java 人工智能
|
人工智能
|
机器学习/深度学习 人工智能
|
人工智能 BI Java
HDU 1003
Max Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 105228    Accepted Submission(s): 242...
903 0
|
固态存储
hdu 2333 Assemble
点击打开链接hdu 2333 思路:二分答案 分析: 1 首先我们遇到这类无从下手的题目的时候,我们首先应该考虑的就是利用二分答案,其它我们无从下手。
866 0
|
人工智能
hdu2084数塔
经典问题了,题意我就不叙述了(题目是中文的~) 分析:dp[i][j]表示在第i行第j个位置上能取得的最大和,那么要从最后一行开始算起,到塔顶结束:dp[i][j] = a[i][j]+max(dp[i+1][j], dp[i+1][j+1]), 边界条件是dp[n][j] = a[n][j]; ...
673 0
hdu 1754 I Hate It
点击打开链接hdu 1754 思路: 线段树+单点更新 分析: 1 线段树的水题 代码: /************************************************ * By: chenguolin ...
789 0
hdu 3746 Cyclic Nacklace
点击打开链接hdu 3746 思路:kmp+字符串的最小循环节问题 分析: 1 题目要求的是给定一个字符串,问我们还需要添加几个字符可以构成一个由n个循环节组成的字符串。
708 0
hdu 1298 T9
点击打开链接hdu 1298 题意:题目说的是在那遥远的星球有一款叫诺基亚的手机,键盘采用题目的图的样式。给定n个单词的出现的概率,规定是相加的比如hell出现为4,hello概率为3则hell的概率为7。
762 0