結果

問題 No.1705 Mode of long array
ユーザー tentententen
提出日時 2023-11-30 17:11:04
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 3,066 bytes
コンパイル時間 3,425 ms
コンパイル使用メモリ 89,548 KB
実行使用メモリ 62,716 KB
最終ジャッジ日時 2024-09-26 14:12:06
合計ジャッジ時間 36,195 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
37,048 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 420 ms
47,028 KB
testcase_24 AC 417 ms
46,940 KB
testcase_25 AC 446 ms
46,892 KB
testcase_26 AC 431 ms
46,984 KB
testcase_27 AC 424 ms
46,908 KB
testcase_28 AC 417 ms
46,960 KB
testcase_29 AC 416 ms
46,880 KB
testcase_30 AC 401 ms
46,912 KB
testcase_31 AC 412 ms
46,864 KB
testcase_32 AC 423 ms
46,960 KB
testcase_33 AC 999 ms
60,136 KB
testcase_34 AC 1,016 ms
59,904 KB
testcase_35 AC 971 ms
60,232 KB
testcase_36 AC 968 ms
60,260 KB
testcase_37 AC 1,000 ms
60,152 KB
testcase_38 AC 1,012 ms
60,208 KB
testcase_39 AC 980 ms
60,056 KB
testcase_40 AC 971 ms
60,072 KB
testcase_41 AC 977 ms
60,168 KB
testcase_42 AC 981 ms
60,080 KB
testcase_43 AC 582 ms
57,720 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
        Count[] counts = new Count[m];
        TreeSet<Count> all = new TreeSet<>();
        for (int i = 0; i < m; i++) {
            counts[i] = new Count(i, sc.nextLong());
            all.add(counts[i]);
        }
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        while (q-- > 0) {
            int type = sc.nextInt();
            int idx = sc.nextInt() - 1;
            long value = sc.nextLong();
            if (type == 1) {
                all.remove(counts[idx]);
                counts[idx].value += value;
                all.add(counts[idx]);
            } else if (type == 2) {
                all.remove(counts[idx]);
                counts[idx].value += value;
                all.add(counts[idx]);
            } else {
                sb.append(all.last().idx + 1).append("\n");
            }
        }
        System.out.print(sb);
    }
    
    static class Count implements Comparable<Count> {
        int idx;
        long value;
        
        public Count(int idx, long value) {
            this.idx = idx;
            this.value = value;
        }
        
        public int hashCode() {
            return idx;
        }
        
        public int compareTo(Count another) {
            if (value == another.value) {
                return idx - another.idx;
            } else if (value < another.value) {
                return -1;
            } else {
                return 1;
            }
        }
        
        public boolean equals(Object another) {
            return hashCode() == another.hashCode();
        }
    }
}
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();
    }
    
}
0