結果

問題 No.865 24時間降水量
ユーザー htensaihtensai
提出日時 2020-05-15 17:48:24
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,135 bytes
コンパイル時間 4,192 ms
コンパイル使用メモリ 77,500 KB
実行使用メモリ 77,348 KB
最終ジャッジ日時 2023-10-19 08:46:17
合計ジャッジ時間 12,379 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 142 ms
57,412 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 150 ms
55,436 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 143 ms
57,284 KB
testcase_19 AC 145 ms
57,776 KB
testcase_20 AC 143 ms
57,556 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[i] = 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