結果
問題 | No.1705 Mode of long array |
ユーザー | tenten |
提出日時 | 2023-03-27 14:29:02 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,003 ms / 3,000 ms |
コード長 | 3,214 bytes |
コンパイル時間 | 3,323 ms |
コンパイル使用メモリ | 85,820 KB |
実行使用メモリ | 60,356 KB |
最終ジャッジ日時 | 2024-09-19 10:24:35 |
合計ジャッジ時間 | 36,887 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 53 ms
37,024 KB |
testcase_01 | AC | 54 ms
37,184 KB |
testcase_02 | AC | 54 ms
37,256 KB |
testcase_03 | AC | 142 ms
40,376 KB |
testcase_04 | AC | 117 ms
39,208 KB |
testcase_05 | AC | 140 ms
39,744 KB |
testcase_06 | AC | 186 ms
42,876 KB |
testcase_07 | AC | 194 ms
45,236 KB |
testcase_08 | AC | 192 ms
44,068 KB |
testcase_09 | AC | 188 ms
44,664 KB |
testcase_10 | AC | 185 ms
44,324 KB |
testcase_11 | AC | 190 ms
44,352 KB |
testcase_12 | AC | 198 ms
44,388 KB |
testcase_13 | AC | 788 ms
57,532 KB |
testcase_14 | AC | 610 ms
51,768 KB |
testcase_15 | AC | 460 ms
48,672 KB |
testcase_16 | AC | 569 ms
49,512 KB |
testcase_17 | AC | 444 ms
48,540 KB |
testcase_18 | AC | 455 ms
48,020 KB |
testcase_19 | AC | 663 ms
51,244 KB |
testcase_20 | AC | 490 ms
49,456 KB |
testcase_21 | AC | 677 ms
54,304 KB |
testcase_22 | AC | 867 ms
59,592 KB |
testcase_23 | AC | 415 ms
46,868 KB |
testcase_24 | AC | 402 ms
46,960 KB |
testcase_25 | AC | 431 ms
46,848 KB |
testcase_26 | AC | 417 ms
47,076 KB |
testcase_27 | AC | 420 ms
46,912 KB |
testcase_28 | AC | 415 ms
46,888 KB |
testcase_29 | AC | 406 ms
46,816 KB |
testcase_30 | AC | 403 ms
46,800 KB |
testcase_31 | AC | 414 ms
46,960 KB |
testcase_32 | AC | 424 ms
47,028 KB |
testcase_33 | AC | 975 ms
60,180 KB |
testcase_34 | AC | 955 ms
60,116 KB |
testcase_35 | AC | 969 ms
60,232 KB |
testcase_36 | AC | 956 ms
60,240 KB |
testcase_37 | AC | 969 ms
60,288 KB |
testcase_38 | AC | 965 ms
60,112 KB |
testcase_39 | AC | 998 ms
60,176 KB |
testcase_40 | AC | 989 ms
60,020 KB |
testcase_41 | AC | 969 ms
60,116 KB |
testcase_42 | AC | 1,003 ms
60,312 KB |
testcase_43 | AC | 627 ms
58,148 KB |
testcase_44 | AC | 566 ms
57,576 KB |
testcase_45 | AC | 585 ms
57,868 KB |
testcase_46 | AC | 603 ms
57,984 KB |
testcase_47 | AC | 616 ms
57,720 KB |
testcase_48 | AC | 545 ms
57,144 KB |
testcase_49 | AC | 795 ms
59,160 KB |
testcase_50 | AC | 787 ms
60,356 KB |
testcase_51 | AC | 803 ms
58,660 KB |
testcase_52 | AC | 755 ms
58,440 KB |
testcase_53 | AC | 761 ms
60,256 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> orders = new TreeSet<>(); for (int i = 0; i < m; i++) { units[i] = new Unit(i, sc.nextLong()); orders.add(units[i]); } int q = sc.nextInt(); StringBuilder sb = new StringBuilder(); while (q-- > 0) { int t = sc.nextInt(); int x = sc.nextInt() - 1; long y = sc.nextLong(); if (t == 1) { orders.remove(units[x]); units[x].add(y); orders.add(units[x]); } else if (t == 2) { orders.remove(units[x]); units[x].add(-y); orders.add(units[x]); } else { sb.append(orders.first().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 another.idx - idx; } else if (value < another.value) { return 1; } else { return -1; } } public int hashCode() { return idx; } public boolean equals(Object o) { Unit x = (Unit)o; return idx == x.idx; } public void add(long x) { value += x; } public String toString() { return "{" + idx + "," + value + "}"; } } } 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(); } }