結果

問題 No.865 24時間降水量
ユーザー ks2mks2m
提出日時 2019-08-16 22:00:26
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,254 bytes
コンパイル時間 2,703 ms
コンパイル使用メモリ 78,168 KB
実行使用メモリ 80,112 KB
最終ジャッジ日時 2023-10-23 23:18:37
合計ジャッジ時間 8,014 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
53,720 KB
testcase_01 AC 56 ms
53,720 KB
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 AC 55 ms
53,724 KB
testcase_19 AC 55 ms
53,720 KB
testcase_20 AC 57 ms
53,712 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 = Math.max(t[i] - 23, 0); j < Math.min(t[i] + 24, n); j++) {
				b[j] += d;
				max = Math.max(max, b[j]);
			}
			pw.println(max);
		}
		pw.flush();
	}
}
0