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);

        }

    }

}
时间: 2024-10-23 16:34:14

HDOJ(HDU) 1718 Rank(水题、、、)的相关文章

HDU 1228 模拟水题

字符串的水题 用了两种方法做的 感觉做法都很山寨 题目很水 如果不限制小于100会很好   #include <iostream> #include<cstdio> #include<cstring> using namespace std; int pd(string s) { if(s=="zero") return 0; if(s=="one") return 1; if(s=="two") return

HDOJ/HDU 2568 前进(简单题)

Problem Description 轻松通过墓碑,进入古墓后,才发现里面别有洞天. 突然,Yifenfei发现自己周围是黑压压的一群蝙蝠,个个扇动翅膀正准备一起向他发起进攻! 形势十分危急! 好在此时的yifenfei已经不是以前那个经常被lemon抢走MM的菜鸟了!面对众多蝙蝠的嗜血狂攻,只见yifenfei使出轻灵的剑法,刷,刷,刷,瞬间搞定-- 现已知yifenfei使用了2招(剑招A和剑招B):剑招A,一招能杀死一半的蝙蝠.但是如果当前的蝙蝠数为奇数,那么就必须先出一招剑招B杀死其中

hdu 1056 HangOver 水题

HangOver             很水的一道题,无论是时间空间都约等于没有要求,直接模拟就可以过了. /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #include <cstdio> int main() { double aim,now; int i; while(~scanf("%lf&

HDOJ 1056 HangOver(水题)

Problem Description How far can you make a stack of cards overhang a table? If you have one card, you can create a maximum overhang of half a card length. (We're assuming that the cards must be perpendicular to the table.) With two cards you can make

HDOJ(HDU) 1587 Flowers(水、、)

Problem Description As you know, Gardon trid hard for his love-letter, and now he's spending too much time on choosing flowers for Angel. When Gardon entered the flower shop, he was frightened and dazed by thousands kinds of flowers. "How can I choos

HDOJ/HDU 1256 画8(绞下思维~水题)

Problem Description 谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发. Input 输入的第一行为一个整数N,表示后面有N组数据. 每组数据中有一个字符和一个整数,字符表示画笔,整数(>=5)表示高度. Output 画横线总是一个字符粗,竖线随着总高度每增长6而增加1个字符宽.当总高度从5增加到6时,其竖线宽度从1增长到2.下圈高度不小于上圈高度,但应尽量接近上圈高度,且下圈的内径呈正方形. 每画一个"8"应空一行,但最前和最后都无空

HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)

Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or the film of the same name by Stanley Kubrick. In it a spaceship is sent from Earth to Saturn. The crew is put into stasis for the long flight, only tw

HDOJ(HDU) 1555 How many days?(水题)

Problem Description 8600的手机每天消费1元,每消费K元就可以获赠1元,一开始8600有M元,问最多可以用多少天? Input 输入包括多个测试实例.每个测试实例包括2个整数M, k,(2 <= k <= M <= 1000).M = 0, k = 0代表输入结束. Output 对于每个测试实例输出一个整数,表示M元可以用的天数. Sample Input 2 2 4 3 0 0 Sample Output 3 5 水题.... import java.util.

HDOJ(HDU) 1859 最小长方形(水题、、)

Problem Description 给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内.长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内. Input 测试输入包含若干测试用例,每个测试用例由一系列坐标组成,每对坐标占一行,其中|x|和|y|小于 231:一对0 坐标标志着一个测试用例的结束.注意(0, 0)不作为任何一个测试用例里面的点.一个没有点的测试用例标志着整个输入的结束. Output 对每个测试用例,在1行内输出2对整数