結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー htensaihtensai
提出日時 2020-05-12 10:25:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,152 ms / 4,000 ms
コード長 1,963 bytes
コンパイル時間 4,695 ms
コンパイル使用メモリ 76,128 KB
実行使用メモリ 80,932 KB
最終ジャッジ日時 2023-10-01 03:06:32
合計ジャッジ時間 44,597 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,114 ms
80,648 KB
testcase_01 AC 1,109 ms
80,888 KB
testcase_02 AC 1,001 ms
71,496 KB
testcase_03 AC 1,023 ms
69,148 KB
testcase_04 AC 1,026 ms
68,784 KB
testcase_05 AC 1,049 ms
76,380 KB
testcase_06 AC 1,090 ms
80,932 KB
testcase_07 AC 1,152 ms
80,396 KB
testcase_08 AC 1,074 ms
76,484 KB
testcase_09 AC 972 ms
68,960 KB
testcase_10 AC 928 ms
68,872 KB
testcase_11 AC 958 ms
68,704 KB
testcase_12 AC 942 ms
68,428 KB
testcase_13 AC 921 ms
68,484 KB
testcase_14 AC 946 ms
68,944 KB
testcase_15 AC 896 ms
68,528 KB
testcase_16 AC 972 ms
68,588 KB
testcase_17 AC 952 ms
68,624 KB
testcase_18 AC 950 ms
68,632 KB
testcase_19 AC 925 ms
68,960 KB
testcase_20 AC 924 ms
68,632 KB
testcase_21 AC 903 ms
69,268 KB
testcase_22 AC 933 ms
68,844 KB
testcase_23 AC 921 ms
68,672 KB
testcase_24 AC 906 ms
68,824 KB
testcase_25 AC 947 ms
68,336 KB
testcase_26 AC 872 ms
68,800 KB
testcase_27 AC 949 ms
68,680 KB
testcase_28 AC 921 ms
68,664 KB
testcase_29 AC 944 ms
68,380 KB
testcase_30 AC 117 ms
55,528 KB
testcase_31 AC 120 ms
55,704 KB
testcase_32 AC 974 ms
69,168 KB
testcase_33 AC 975 ms
69,036 KB
testcase_34 AC 978 ms
69,268 KB
testcase_35 AC 120 ms
56,052 KB
testcase_36 AC 120 ms
55,852 KB
testcase_37 AC 139 ms
56,236 KB
testcase_38 AC 139 ms
55,948 KB
testcase_39 AC 202 ms
58,428 KB
testcase_40 AC 194 ms
58,920 KB
testcase_41 AC 347 ms
60,076 KB
testcase_42 AC 333 ms
59,920 KB
testcase_43 AC 350 ms
60,680 KB
testcase_44 AC 351 ms
60,636 KB
testcase_45 AC 202 ms
58,804 KB
testcase_46 AC 351 ms
60,300 KB
testcase_47 AC 358 ms
60,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static int[] dp;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		HashMap<Integer, PriorityQueue<Team>> all = new HashMap<>();
		for (int i = 0; i < n; i++) {
		    Team t = new Team(i, sc.nextInt(), sc.nextInt(), sc.nextInt());
		    if (!all.containsKey(t.univ)) {
		        all.put(t.univ, new PriorityQueue<>());
		    }
		    all.get(t.univ).add(t);
		}
		PriorityQueue<Team> queue = new PriorityQueue<>();
		for (PriorityQueue<Team> tmp : all.values()) {
		    int idx = 0;
		    while (tmp.size() > 0) {
		        Team t = tmp.poll();
		        t.rank = idx;
		        idx++;
		        queue.add(t);
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < k; i++) {
		    sb.append(queue.poll().idx).append("\n");
		}
		System.out.print(sb);
	}
	
	static int dfw(int x) {
	    if (x < 10) {
	        return x;
	    }
	    if (dp[x] != -1) {
	        return dp[x];
	    }
	    int prev = x % 10;
	    x /= 10;
	    int next = 0;
	    while (x > 0) {
	        int cur = x % 10;
	        x /= 10;
	        next *= 10;
	        next += (prev + cur) % 10 + (prev + cur) / 10;
	        prev = cur;
	    }
	    dp[x] = dfw(next);
	    return dp[x];
	}
	
	static class Team implements Comparable<Team> {
	    int idx;
	    int score;
	    int penalty;
	    int univ;
	    int rank;
	    
	    public Team(int idx, int score, int penalty, int univ) {
	        this.idx = idx;
	        this.score = score;
	        this.penalty = penalty;
	        this.univ = univ;
	    }
	    
	    public int compareTo(Team another) {
	        if (score == another.score) {
	            if (rank == another.rank) {
	                return penalty - another.penalty;
	            } else {
	                return rank - another.rank;
	            }
	        } else {
	            return another.score - score;
	        }
	    }
	}
}
0