結果
問題 | No.1705 Mode of long array |
ユーザー | tenten |
提出日時 | 2021-11-29 17:47:32 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 956 ms / 3,000 ms |
コード長 | 2,681 bytes |
コンパイル時間 | 5,464 ms |
コンパイル使用メモリ | 78,252 KB |
実行使用メモリ | 60,432 KB |
最終ジャッジ日時 | 2024-07-02 13:01:28 |
合計ジャッジ時間 | 34,210 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
37,280 KB |
testcase_01 | AC | 55 ms
36,824 KB |
testcase_02 | AC | 53 ms
36,896 KB |
testcase_03 | AC | 132 ms
40,848 KB |
testcase_04 | AC | 103 ms
39,144 KB |
testcase_05 | AC | 138 ms
40,676 KB |
testcase_06 | AC | 177 ms
42,756 KB |
testcase_07 | AC | 188 ms
46,032 KB |
testcase_08 | AC | 177 ms
45,116 KB |
testcase_09 | AC | 180 ms
44,728 KB |
testcase_10 | AC | 173 ms
44,524 KB |
testcase_11 | AC | 178 ms
42,940 KB |
testcase_12 | AC | 177 ms
44,700 KB |
testcase_13 | AC | 745 ms
53,996 KB |
testcase_14 | AC | 549 ms
50,592 KB |
testcase_15 | AC | 447 ms
48,724 KB |
testcase_16 | AC | 547 ms
50,096 KB |
testcase_17 | AC | 418 ms
48,552 KB |
testcase_18 | AC | 419 ms
48,404 KB |
testcase_19 | AC | 607 ms
50,776 KB |
testcase_20 | AC | 471 ms
50,100 KB |
testcase_21 | AC | 608 ms
52,612 KB |
testcase_22 | AC | 835 ms
58,392 KB |
testcase_23 | AC | 383 ms
47,276 KB |
testcase_24 | AC | 396 ms
46,820 KB |
testcase_25 | AC | 390 ms
46,484 KB |
testcase_26 | AC | 404 ms
46,676 KB |
testcase_27 | AC | 394 ms
47,776 KB |
testcase_28 | AC | 394 ms
46,864 KB |
testcase_29 | AC | 386 ms
46,756 KB |
testcase_30 | AC | 393 ms
47,816 KB |
testcase_31 | AC | 397 ms
47,412 KB |
testcase_32 | AC | 392 ms
47,564 KB |
testcase_33 | AC | 889 ms
60,308 KB |
testcase_34 | AC | 903 ms
60,304 KB |
testcase_35 | AC | 956 ms
60,432 KB |
testcase_36 | AC | 907 ms
60,116 KB |
testcase_37 | AC | 926 ms
60,424 KB |
testcase_38 | AC | 918 ms
60,100 KB |
testcase_39 | AC | 919 ms
60,244 KB |
testcase_40 | AC | 918 ms
60,156 KB |
testcase_41 | AC | 933 ms
60,112 KB |
testcase_42 | AC | 894 ms
60,244 KB |
testcase_43 | AC | 569 ms
56,456 KB |
testcase_44 | AC | 518 ms
56,172 KB |
testcase_45 | AC | 531 ms
57,472 KB |
testcase_46 | AC | 570 ms
58,016 KB |
testcase_47 | AC | 558 ms
57,588 KB |
testcase_48 | AC | 552 ms
56,752 KB |
testcase_49 | AC | 691 ms
57,856 KB |
testcase_50 | AC | 727 ms
58,048 KB |
testcase_51 | AC | 711 ms
59,624 KB |
testcase_52 | AC | 721 ms
58,092 KB |
testcase_53 | AC | 716 ms
58,192 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); long n = sc.nextLong(); int m = sc.nextInt(); Numbers[] numbers = new Numbers[m + 1]; TreeSet<Numbers> set = new TreeSet<>(); for (int i = 1; i <= m; i++) { numbers[i] = new Numbers(i, sc.nextLong()); set.add(numbers[i]); } int q = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { int type = sc.nextInt(); int x = sc.nextInt(); long y = sc.nextLong(); if (type == 1) { set.remove(numbers[x]); numbers[x].add(y); set.add(numbers[x]); } else if (type == 2) { set.remove(numbers[x]); numbers[x].add(-y); set.add(numbers[x]); } else { sb.append(set.last()).append("\n"); } } System.out.print(sb); } static class Numbers implements Comparable<Numbers> { int num; long value; public Numbers(int num, long value) { this.num = num; this.value = value; } public int hashCode() { return num; } public boolean equals(Object o) { Numbers x = (Numbers)o; return x.num == num; } public int compareTo(Numbers another) { if (value == another.value) { return num - another.num; } else if (value < another.value) { return -1; } else { return 1; } } public String toString() { return String.valueOf(num); } public void add(long x) { value += x; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); 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 String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }