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(HDU) 1718 Rank(水题、、、)的更多相关文章
- hdu 1718 Rank
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1718 Rank Description Jackson wants to know his rank ...
- hdu 5210 delete 水题
Delete Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5210 D ...
- HDOJ/HDU 2568 前进(简单题)
Problem Description 轻松通过墓碑,进入古墓后,才发现里面别有洞天. 突然,Yifenfei发现自己周围是黑压压的一群蝙蝠,个个扇动翅膀正准备一起向他发起进攻! 形势十分危急! 好在 ...
- hdu 1251 (Trie水题)
统计难题 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others)Total Submi ...
- HDU 5703 Desert 水题 找规律
已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...
- HDU 4493 Tutor 水题的收获。。
题目: http://acm.hdu.edu.cn/showproblem.php?pid=4493 题意我都不好意思说,就是求12个数的平均数... 但是之所以发博客,显然有值得发的... 这个题最 ...
- hdu 4802 GPA 水题
GPA Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4802 Des ...
- hdu 4493 Tutor 水题
Tutor Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4493 D ...
- HDU 1718 Rank counting sort解法
本题是利用counting sort的思想去解题. 注意本题,好像利用直接排序,然后查找rank是会直接被判WA的.奇怪的推断系统. 由于分数值的范围是0到100,很小,而student 号码又很大, ...
随机推荐
- diy 电脑 重装系统
1\组装好电脑 2\硬盘的红灯只亮一会,找不到 硬盘 .bios里 硬盘设置里 IDE修改为 ACHI即可. 3\老毛桃 \ 用桌面的那个分区软件 分区 100G,300G 4\找到U盘 的iso 文 ...
- CSRF跨站点请求伪造漏洞问题
最近在写php,项目写完后送检发现一个漏洞问题CSRF,强行拖了我一天的时间,沉迷解决问题,茶饭不思,日渐消瘦,时间比较赶,这篇比较糙,凑合看下. 好了废话不多说下面是今天的解决方案. 博主用的是Th ...
- Apache MINA 框架之Handler介绍
IoHandler 具备以下几个功能: sessionCreated sessionOpened sessionClosed sessionIdle exceptionCaught messageRe ...
- JSON 解析(门店)
package com.j1.mai.action; import java.io.BufferedReader; import java.io.IOException; import java.io ...
- Android传感器的使用(GravieySensor)
这里以重力传感器为例说明 第一步:创建一个SensorManager对象,用来管理或者获取传感器 SensorManager sm = (SensorManager) this.getSystemSe ...
- HDU5317
题意:定义一个数K,最小质因数形式为K = a*b*c形式(如12 = 2*2*3),相同只取一个(所以12只能取2,3两个,既F[12]=2)给L,R区间,找出区间内最大的F[x](L<=x& ...
- Android中px、dp、sp的区别
px: 即像素,1px代表屏幕上一个物理的像素点: px单位不被建议使用,因为同样100px的图片,在不同手机上显示的实际大小可能不同,如下图所示(图片来自android developer guid ...
- http请求头响应头大全
转:http://www.jb51.net/article/51951.htm 本文为多篇“HTTP请求头相关文章”及<HTTP权威指南>一书的阅读后个人汇总整理版,以便于理解. 通常HT ...
- underscorejs-contains学习
2.12 contains 2.12.1 语法: _.contains(list, item, fromIndex, guard) 2.12.2 说明: list集合包含指定的值则返回true,否则返 ...
- ORA-00933 UNION 与 ORDER BY
原文:http://blog.csdn.net/lwei_998/article/details/6093807 The UNION operator returns only distinct ro ...