- import java.io.BufferedInputStream;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(new BufferedInputStream(System.in));
- int student = sc.nextInt();
- while (student != 0) {
- int question = sc.nextInt();
- int score[] = new int[question];// score of each qes
- String id[] = new String[student];//
- int sumScore[] = new int[student];// sum score of each student
- int standard = sc.nextInt();
- for (int i = 0; i < question; i++) {// get the score of each qes
- score[i] = sc.nextInt();
- }
- for (int i = 0; i < student; i++) {
- id[i] = sc.next();
- int answeredQes = sc.nextInt();// get the num of the student answered
- for (int j = 0; j < answeredQes; j++) {
- sumScore[i] += score[sc.nextInt() - 1];
- }
- }
- for (int i = 0; i < student; i++) {
- for (int j = i + 1; j < student; j++) {
- if (sumScore[i] < sumScore[j] || sumScore[i] == sumScore[j]
- && id[i].compareTo(id[j]) > 0) {
- int scoretmp = sumScore[i];
- sumScore[i] = sumScore[j];
- sumScore[j] = scoretmp;
- String nametmp = id[i];
- id[i] = id[j];
- id[j] = nametmp;
- }
- }
- }
- int overStandard = 0;
- for (int i = 0; i < student; i++) {
- if (sumScore[i] >= standard) {
- overStandard++;
- }
- }
- System.out.println(overStandard);
- for (int i = 0; i < student; i++) {
- if (sumScore[i] >= standard) {
- System.out.println(id[i] + " " + sumScore[i]);
- }
- }
- // another case
- student = sc.nextInt();
- }
- }
- }
一次AC。简直就是大水题啊。。。九度那里居然还是4星题。。。不过用C写会稍麻烦一点。。