結果

問題 No.1705 Mode of long array
ユーザー tentententen
提出日時 2023-11-30 17:11:04
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 3,066 bytes
コンパイル時間 3,877 ms
コンパイル使用メモリ 92,312 KB
実行使用メモリ 75,996 KB
最終ジャッジ日時 2023-11-30 17:11:42
合計ジャッジ時間 36,606 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
53,992 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 410 ms
62,232 KB
testcase_24 AC 411 ms
62,320 KB
testcase_25 AC 442 ms
62,196 KB
testcase_26 AC 401 ms
62,220 KB
testcase_27 AC 396 ms
62,272 KB
testcase_28 AC 447 ms
62,304 KB
testcase_29 AC 391 ms
62,320 KB
testcase_30 AC 409 ms
62,284 KB
testcase_31 AC 425 ms
62,308 KB
testcase_32 AC 402 ms
62,292 KB
testcase_33 AC 1,006 ms
73,524 KB
testcase_34 AC 974 ms
73,344 KB
testcase_35 AC 941 ms
73,444 KB
testcase_36 AC 981 ms
73,432 KB
testcase_37 AC 991 ms
73,324 KB
testcase_38 AC 955 ms
73,640 KB
testcase_39 AC 975 ms
71,564 KB
testcase_40 AC 951 ms
73,324 KB
testcase_41 AC 966 ms
73,420 KB
testcase_42 AC 988 ms
73,552 KB
testcase_43 AC 599 ms
71,228 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