結果
| 問題 |
No.865 24時間降水量
|
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2020-05-15 17:48:24 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,135 bytes |
| コンパイル時間 | 2,459 ms |
| コンパイル使用メモリ | 77,388 KB |
| 実行使用メモリ | 63,216 KB |
| 最終ジャッジ日時 | 2024-09-19 05:00:01 |
| 合計ジャッジ時間 | 11,986 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 11 RE * 5 |
ソースコード
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);
}
}
htensai