結果

問題 No.865 24時間降水量
ユーザー htensaihtensai
提出日時 2020-05-15 17:49:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,440 ms / 2,000 ms
コード長 1,138 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 78,068 KB
実行使用メモリ 77,072 KB
最終ジャッジ日時 2023-10-19 08:48:47
合計ジャッジ時間 11,534 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
57,536 KB
testcase_01 AC 139 ms
57,840 KB
testcase_02 AC 142 ms
57,772 KB
testcase_03 AC 138 ms
57,636 KB
testcase_04 AC 140 ms
57,688 KB
testcase_05 AC 214 ms
59,860 KB
testcase_06 AC 217 ms
59,940 KB
testcase_07 AC 214 ms
59,980 KB
testcase_08 AC 218 ms
58,088 KB
testcase_09 AC 217 ms
59,960 KB
testcase_10 AC 324 ms
61,972 KB
testcase_11 AC 320 ms
61,872 KB
testcase_12 AC 323 ms
61,840 KB
testcase_13 AC 332 ms
61,644 KB
testcase_14 AC 340 ms
61,680 KB
testcase_15 AC 1,362 ms
77,060 KB
testcase_16 AC 1,399 ms
77,060 KB
testcase_17 AC 1,440 ms
77,072 KB
testcase_18 AC 135 ms
57,628 KB
testcase_19 AC 141 ms
57,492 KB
testcase_20 AC 138 ms
57,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n + 1];
        int[] sums = new int[n + 1];
        int[] total24 = new int[n + 1 - 23];
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
            sums[i] = sums[i - 1] + arr[i];
        }
        int max = 0;
        for (int i = 24; i <= n; i++) {
            total24[i - 23] = sums[i] - sums[i - 24];
            max = Math.max(total24[i - 23], max);
        }
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            int time = sc.nextInt();
            int value = sc.nextInt();
            int add = value - arr[time];
            arr[time] = value;
            for (int j = Math.max(time - 23, 1); j <= time && j < total24.length; j++) {
                total24[j] += add;
                max = Math.max(max, total24[j]);
            }
            sb.append(max).append("\n");
        }
        System.out.print(sb);
    }
}
0