# 杭电acm 1236 排名 list排序

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 18105 Accepted Submission(s): 6598

Problem Description

Input

< 1000 )、考题数M ( 0 < M < = 10 )、分数线（正整数）G；第2行排序给出第1题至第M题的正整数分值；以下N行，每行给出一

（题目号由1到M）。

Output

Sample Input
4 5 25
10 10 12 13 15
CS004 3 5 1 3
CS003 5 2 4 1 3 5
CS002 2 1 2
CS001 3 2 3 5
1 2 40
10 30
CS001 1 2
2 3 20
10 10 10
CS000000000000000001 0
CS000000000000000002 2 1 2
0

Sample Output
3
CS003 60
CS001 37
CS004 37
0
1
CS000000000000000002 20

Hint

Huge input, scanf is recommended.

Source

import java.awt.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Scanner;

public class Main {

/**
* @param args
*/
public static class Student {
String num;
int n = 0;
int score = 0;
}
//实现comparator的接口
public static class ComparatorStudent implements Comparator{

@Override
public int compare(Object arg0, Object arg1) {
// TODO Auto-generated method stub
Student student1=(Student)arg0;
Student student2 = (Student)arg1;
int flag;
if(student1.score>student2.score){
flag=-1;
}else if(student1.score==student2.score){
flag =0;
}else{
flag=1;
}
//成绩相同时。就按考号排序
if(flag==0){
return student1.num.compareTo(student2.num);
}else{
return flag;
}
}

}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
while (true) {
int N = in.nextInt();
if (N == 0) {
break;
}
int M = in.nextInt();
int avg = in.nextInt();
int[] eves = new int[M];
for (int i = 0;i<M;i++){
eves[i] = in.nextInt();
}
ArrayList<Student> L = new ArrayList<Student>();
while(N!=0){
N--;
Student stu = new Student();
stu.num = in.next();
stu.n = in.nextInt();
for (int i = 0;i<stu.n;i++){
int a =in.nextInt();
stu.score += eves[a-1];
}
}
int peo=0;
ComparatorStudent comparator = new ComparatorStudent();
Collections.sort(L,comparator);
for (Student student : L) {
if(student.score>=avg){
peo++;
}
}
System.out.println(peo);
for (Student student : L) {
if(student.score>=avg){
System.out.println(student.num+" "+student.score);
}
}
}
}
}



• 本文已收录于以下专栏：

## 杭电1236排名

• z8110
• 2015-09-16 18:27
• 240

## hdu 杭电 1.3.1 1236 排名

• D_Fur
• 2012-03-28 15:54
• 2077

HDU 1236 排名 题解

## 杭电acm之1106-排序

Problem Description 输入一行数字，如果我们把这行数字中的‘5’都看成空格，那么就得到一行用空格分割的若干非负整数（可能有些整数以‘0’开头，这些头部的‘0’应该被忽略掉，除非...

## HDU 1236 - 排名

Problem Description 今天的上机考试虽然有实时的Ranklist，但上面的排名只是根据完成的题数排序，没有考虑 每题的分值，所以并不是最后的排名。给定录取分数线，请你写程序找出...

举报原因： 您举报文章：深度学习：神经网络中的前向传播和反向传播算法推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)