[JAVA][HDU 1236][九度 1014][排名]

[java]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. import java.io.BufferedInputStream;  
  2. import java.util.Scanner;  
  3.   
  4. public class Main {  
  5.   
  6.     public static void main(String[] args) {  
  7.         Scanner sc = new Scanner(new BufferedInputStream(System.in));  
  8.         int student = sc.nextInt();  
  9.         while (student != 0) {  
  10.             int question = sc.nextInt();  
  11.             int score[] = new int[question];// score of each qes  
  12.             String id[] = new String[student];//   
  13.             int sumScore[] = new int[student];// sum score of each student  
  14.             int standard = sc.nextInt();  
  15.             for (int i = 0; i < question; i++) {// get the score of each qes  
  16.                 score[i] = sc.nextInt();  
  17.             }  
  18.             for (int i = 0; i < student; i++) {  
  19.                 id[i] = sc.next();  
  20.                 int answeredQes = sc.nextInt();// get the num of the student answered  
  21.                 for (int j = 0; j < answeredQes; j++) {  
  22.                     sumScore[i] += score[sc.nextInt() - 1];  
  23.                 }  
  24.             }  
  25.   
  26.             for (int i = 0; i < student; i++) {  
  27.                 for (int j = i + 1; j < student; j++) {  
  28.                     if (sumScore[i] < sumScore[j] || sumScore[i] == sumScore[j]  
  29.                             && id[i].compareTo(id[j]) > 0) {  
  30.                         int scoretmp = sumScore[i];  
  31.                         sumScore[i] = sumScore[j];  
  32.                         sumScore[j] = scoretmp;  
  33.   
  34.                         String nametmp = id[i];  
  35.                         id[i] = id[j];  
  36.                         id[j] = nametmp;  
  37.                     }  
  38.                 }  
  39.             }  
  40.   
  41.             int overStandard = 0;  
  42.             for (int i = 0; i < student; i++) {  
  43.                 if (sumScore[i] >= standard) {  
  44.                     overStandard++;  
  45.                 }  
  46.             }  
  47.   
  48.             System.out.println(overStandard);  
  49.   
  50.             for (int i = 0; i < student; i++) {  
  51.                 if (sumScore[i] >= standard) {  
  52.                     System.out.println(id[i] + " " + sumScore[i]);  
  53.                 }  
  54.             }  
  55.   
  56.             // another case  
  57.             student = sc.nextInt();  
  58.         }  
  59.     }  
  60. }  




一次AC。简直就是大水题啊。。。九度那里居然还是4星题。。。不过用C写会稍麻烦一点。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值