結果
問題 | No.1705 Mode of long array |
ユーザー | tenten |
提出日時 | 2023-01-13 18:21:38 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 859 ms / 3,000 ms |
コード長 | 2,925 bytes |
コンパイル時間 | 2,736 ms |
コンパイル使用メモリ | 88,596 KB |
実行使用メモリ | 60,364 KB |
最終ジャッジ日時 | 2024-06-06 19:33:57 |
合計ジャッジ時間 | 32,921 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 49 ms
36,788 KB |
testcase_01 | AC | 48 ms
37,024 KB |
testcase_02 | AC | 50 ms
37,056 KB |
testcase_03 | AC | 117 ms
40,572 KB |
testcase_04 | AC | 106 ms
39,000 KB |
testcase_05 | AC | 127 ms
40,732 KB |
testcase_06 | AC | 161 ms
42,632 KB |
testcase_07 | AC | 175 ms
45,044 KB |
testcase_08 | AC | 172 ms
44,500 KB |
testcase_09 | AC | 173 ms
44,892 KB |
testcase_10 | AC | 167 ms
44,440 KB |
testcase_11 | AC | 168 ms
44,036 KB |
testcase_12 | AC | 170 ms
44,404 KB |
testcase_13 | AC | 652 ms
54,368 KB |
testcase_14 | AC | 518 ms
51,936 KB |
testcase_15 | AC | 412 ms
48,420 KB |
testcase_16 | AC | 464 ms
48,628 KB |
testcase_17 | AC | 391 ms
48,264 KB |
testcase_18 | AC | 380 ms
48,372 KB |
testcase_19 | AC | 563 ms
50,492 KB |
testcase_20 | AC | 435 ms
49,636 KB |
testcase_21 | AC | 588 ms
53,932 KB |
testcase_22 | AC | 716 ms
58,604 KB |
testcase_23 | AC | 404 ms
46,416 KB |
testcase_24 | AC | 391 ms
46,564 KB |
testcase_25 | AC | 385 ms
46,664 KB |
testcase_26 | AC | 396 ms
46,700 KB |
testcase_27 | AC | 389 ms
46,768 KB |
testcase_28 | AC | 376 ms
46,396 KB |
testcase_29 | AC | 373 ms
46,520 KB |
testcase_30 | AC | 400 ms
46,768 KB |
testcase_31 | AC | 398 ms
46,676 KB |
testcase_32 | AC | 380 ms
46,904 KB |
testcase_33 | AC | 789 ms
59,804 KB |
testcase_34 | AC | 859 ms
60,364 KB |
testcase_35 | AC | 849 ms
60,360 KB |
testcase_36 | AC | 846 ms
59,948 KB |
testcase_37 | AC | 825 ms
60,132 KB |
testcase_38 | AC | 837 ms
59,980 KB |
testcase_39 | AC | 826 ms
59,860 KB |
testcase_40 | AC | 827 ms
60,048 KB |
testcase_41 | AC | 820 ms
59,668 KB |
testcase_42 | AC | 824 ms
59,920 KB |
testcase_43 | AC | 519 ms
57,596 KB |
testcase_44 | AC | 512 ms
57,584 KB |
testcase_45 | AC | 526 ms
57,816 KB |
testcase_46 | AC | 554 ms
58,052 KB |
testcase_47 | AC | 519 ms
57,548 KB |
testcase_48 | AC | 522 ms
57,712 KB |
testcase_49 | AC | 658 ms
58,656 KB |
testcase_50 | AC | 657 ms
58,236 KB |
testcase_51 | AC | 677 ms
57,764 KB |
testcase_52 | AC | 655 ms
58,744 KB |
testcase_53 | AC | 665 ms
58,500 KB |
ソースコード
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(); long n = sc.nextLong(); int m = sc.nextInt(); Unit[] units = new Unit[m]; TreeSet<Unit> all = new TreeSet<>(); for (int i = 0; i < m; i++) { units[i] = new Unit(i, sc.nextLong()); all.add(units[i]); } StringBuilder sb = new StringBuilder(); int q = sc.nextInt(); while (q-- > 0) { int type = sc.nextInt(); int idx = sc.nextInt() - 1; long value = sc.nextLong(); if (type == 1) { all.remove(units[idx]); units[idx].add(value); all.add(units[idx]); } else if (type == 2) { all.remove(units[idx]); units[idx].add(-value); all.add(units[idx]); } else { sb.append(all.last().idx + 1).append("\n"); } } System.out.print(sb); } static class Unit implements Comparable<Unit> { int idx; long value; public Unit(int idx, long value) { this.idx = idx; this.value = value; } public int compareTo(Unit another) { if (value == another.value) { return idx - another.idx; } else if (value < another.value) { return -1; } else { return 1; } } public void add(long v) { value += v; } } } 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(); } }