結果
問題 | No.1390 Get together |
ユーザー | tenten |
提出日時 | 2023-04-17 09:48:10 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,179 bytes |
コンパイル時間 | 3,929 ms |
コンパイル使用メモリ | 92,240 KB |
実行使用メモリ | 92,852 KB |
最終ジャッジ日時 | 2024-04-20 16:15:58 |
合計ジャッジ時間 | 18,082 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 48 ms
37,016 KB |
testcase_01 | AC | 48 ms
37,180 KB |
testcase_02 | AC | 49 ms
37,256 KB |
testcase_03 | AC | 134 ms
41,036 KB |
testcase_04 | AC | 132 ms
40,628 KB |
testcase_05 | WA | - |
testcase_06 | AC | 132 ms
40,368 KB |
testcase_07 | WA | - |
testcase_08 | AC | 120 ms
40,536 KB |
testcase_09 | AC | 137 ms
41,272 KB |
testcase_10 | AC | 50 ms
37,164 KB |
testcase_11 | AC | 51 ms
37,012 KB |
testcase_12 | AC | 49 ms
37,352 KB |
testcase_13 | WA | - |
testcase_14 | AC | 51 ms
37,128 KB |
testcase_15 | AC | 48 ms
37,148 KB |
testcase_16 | WA | - |
testcase_17 | AC | 740 ms
87,988 KB |
testcase_18 | AC | 517 ms
61,356 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 804 ms
91,428 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 821 ms
91,344 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int k = sc.nextInt(); HashMap<Integer, HashMap<Integer, Integer>> counts = new HashMap<>(); for (int i = 0; i < n; i++) { int b = sc.nextInt(); int c = sc.nextInt(); if (!counts.containsKey(c)) { counts.put(c, new HashMap<>()); } counts.get(c).put(b, counts.get(c).getOrDefault(b, 0) + 1); } int ans = 0; for (HashMap<Integer, Integer> tmp : counts.values()) { int max = 0; int total = 0; for (int x : tmp.values()) { max = Math.max(max, x); total += x; } ans += total - max; } System.out.println(ans); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }