結果

問題 No.865 24時間降水量
ユーザー ks2mks2m
提出日時 2019-08-16 22:12:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 808 ms / 2,000 ms
コード長 1,236 bytes
コンパイル時間 2,633 ms
コンパイル使用メモリ 77,352 KB
実行使用メモリ 79,584 KB
最終ジャッジ日時 2023-10-24 00:09:53
合計ジャッジ時間 8,210 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
53,668 KB
testcase_01 AC 53 ms
53,656 KB
testcase_02 AC 53 ms
53,676 KB
testcase_03 AC 52 ms
53,664 KB
testcase_04 AC 53 ms
53,680 KB
testcase_05 AC 103 ms
52,500 KB
testcase_06 AC 101 ms
54,804 KB
testcase_07 AC 102 ms
54,548 KB
testcase_08 AC 102 ms
54,544 KB
testcase_09 AC 101 ms
54,680 KB
testcase_10 AC 168 ms
58,628 KB
testcase_11 AC 173 ms
58,596 KB
testcase_12 AC 170 ms
58,600 KB
testcase_13 AC 175 ms
58,988 KB
testcase_14 AC 178 ms
58,844 KB
testcase_15 AC 805 ms
79,032 KB
testcase_16 AC 806 ms
79,440 KB
testcase_17 AC 808 ms
79,584 KB
testcase_18 AC 53 ms
53,664 KB
testcase_19 AC 54 ms
53,660 KB
testcase_20 AC 53 ms
53,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		int q = Integer.parseInt(br.readLine());
		int[] t = new int[q];
		int[] v = new int[q];
		for (int i = 0; i < q; i++) {
			sa = br.readLine().split(" ");
			t[i] = Integer.parseInt(sa[0]) - 1;
			v[i] = Integer.parseInt(sa[1]);
		}
		br.close();

		int[] b = new int[n];
		int sum = 0;
		for (int i = 0; i < 24; i++) {
			sum += a[i];
		}
		b[23] = sum;
		for (int i = 24; i < n; i++) {
			sum -= a[i - 24];
			sum += a[i];
			b[i] = sum;
		}

		int max = 0;
		for (int i = 23; i < n; i++) {
			max = Math.max(max, b[i]);
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			int d = v[i] - a[t[i]];
			a[t[i]] = v[i];
			for (int j = t[i]; j < Math.min(t[i] + 24, n); j++) {
				b[j] += d;
				max = Math.max(max, b[j]);
			}
			pw.println(max);
		}
		pw.flush();
	}
}
0