提交总是Wrong Answer,不知道问题出在哪

原来是出现这种情况时

20070101

20070102 100

20070101 80

20070103 90

20070106 100

时,20070101的排名应该是第4名,而不是第3名

代码如下:

import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Scanner;
import java.util.Map;
import java.util.TreeMap;
import java.util.Set;
import java.util.HashSet;public class Main implements Runnable{private Scanner cin;private PrintWriter cout;private static final boolean DEBUG = false;private int stu_num;private Map<Integer, Set<Integer>> map;private void init(){try{if (DEBUG){cin = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream("d:\\program\\intelj\\spoj\\src\\spoj.txt"))));}else{cin = new Scanner(new BufferedReader(new InputStreamReader(System.in)));}cout = new PrintWriter(System.out);}catch (IOException e){e.printStackTrace();}}private boolean input(){if (!cin.hasNextInt()) return false;int  num, score;stu_num = cin.nextInt();num = cin.nextInt(); score = cin.nextInt();map = new TreeMap<>();while (!(num == 0 && score == 0)){if (!map.containsKey(score)){map.put(score, new HashSet<>());}map.get(score).add(num);num = cin.nextInt(); score = cin.nextInt();}return true;}private void solve(){int rank = 0;int score = 0;boolean found = false;for (int key: map.keySet()){if (map.get(key).contains(stu_num)){found = true;score = key;}if (found){if (key > score) rank += map.get(key).size();}}cout.println(rank + 1);}public void run() {init();while(input()){solve();}cout.flush();}public static void main(String[] args){new Thread(new Main()).start();}
}

hdu1.3.2 Rank相关推荐

  1. Rank() over()的用法

    Rank() over()的用法 创建一个test表,并插入6条数据. CREATE TABLE test (a INT,b INT,c CHAR ) INSERT INTO test VALUES( ...

  2. Sparse low rank approximation

    1. Sparse and low rank approximation (source codes) :http://www.ugcs.caltech.edu/~srbecker/wiki/Main ...

  3. Analytic Functions 分析函数(rank over)

    此篇文章是为了学会rank() over()所写. 官方文档 (DENSE_)RANK( ) OVER ([ query_partition_clause ] order_by_clause) ran ...

  4. python使用numpy中的flatten函数将2D numpy数组拉平为1Dnumpy数组、使用np.linalg.matrix_rank函数计算2D numpy数组的秩(rank)

    python使用numpy中的flatten函数将2D numpy数组拉平为1Dnumpy数组.使用np.linalg.matrix_rank函数计算2D numpy数组的秩(rank) 目录

  5. R语言编写自定义函数使用Wilcoxon符号秩检验(Wilcoxon signed rank)实现多分组非参数成对检验(pairwise)、并使用p.adjust函数调整概率值

    R语言编写自定义函数使用Wilcoxon符号秩检验(Wilcoxon signed rank)实现多分组非参数成对检验(Nonparametric pairwise multiple comparis ...

  6. R语言威尔考克森秩和统计分布函数Wilcoxon rank Sum Statistic Distribution(dwilcox, pwilcox, qwilcox rwilcox)实战

    R语言威尔考克森秩和统计分布函数Wilcoxon rank Sum Statistic Distribution(dwilcox, pwilcox, qwilcox & rwilcox)实战 ...

  7. R语言dplyr包使用arrange函数、group_by函数、mutate函数生成分组数据的排名(rank)实战(Rank Variable by Group):升序排名、降序排名以及相同排名的处理

    R语言dplyr包使用arrange函数.group_by函数.mutate函数生成分组数据的排名(rank)实战(Rank Variables by Group):升序排名.降序排名以及相同排名的处 ...

  8. R语言数据排序函数sort, order rank实战

    R语言数据排序函数sort, order & rank实战 目录 R语言数据排序函数sort, order & rank实战 #sort vs. order vs. rank函数基础 ...

  9. R对数秩检验(log rank test)

    R对数秩检验(log rank test) 对数秩检验(log rank test )是比较两组生存曲线的最常用方法. H0:两组生存率无差异. Ha:两组生存率有差异. 如果检验的P值小于某个显著性 ...

最新文章

  1. CPU飙高,频繁GC,怎么排查?
  2. java spring config_Spring重温(二)--Spring JavaConfig
  3. caffe 中的一些参数介绍
  4. FreeMarker 语法教程
  5. jdk lambda表达式的坑
  6. 遍历数组的两种for循环方式以及一种Arrays方式
  7. 前端程序员 学习书籍推荐
  8. OpenGL制作简易地图(一)
  9. git push解决办法: ! [remote rejected] master -> master (pre-receive hook declined)
  10. RFC 协议下载方法
  11. 四层PCB核心板制作3——层叠管理
  12. 计算多边形(polygon)面积的算法原理和python实现
  13. 如何提升网站的浏览率
  14. linux v4l2系统详解,Linux摄像头驱动学习之:(一)V4L2_框架分析
  15. 进入注册表的一些常用命令
  16. 三万块钱6天的区块链培训,我学会了搭建区块链系统框架?
  17. Witkey威客平台测评
  18. 图片点击放大java_Eova列表显示图片并点击放大
  19. 彻底解决tomcat控制台提示至少有一个JAR被扫描用于TLD但尚未包含TLD的问题
  20. 从“不太差”到“卓越”

热门文章

  1. 对象的比较与排序(三):实现IComparableT和IComparerT泛型接口
  2. 冲刺周期二--站立会议01
  3. 几种文件查找命令,whereis ,find ,locate.
  4. php(wamp安装问题)
  5. 【Android】Android 设置Activity窗体 不显示标题和全屏显示
  6. SetWindowRgn注意点
  7. python读取txt文件第一行-python读取文本文件数据
  8. python基础教程教材-Python3零基础教材电子书合集
  9. 学python最好的方式-你们都是怎么学 Python 的?
  10. 对于python来说、一个模块就是一个文件-PYTHON中的包和模块