結果

問題 No.865 24時間降水量
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-18 09:34:21
言語 Java21
(openjdk 21)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,060 bytes
コンパイル時間 1,967 ms
コンパイル使用メモリ 77,128 KB
実行使用メモリ 90,832 KB
最終ジャッジ日時 2024-04-08 22:49:06
合計ジャッジ時間 15,098 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
56,016 KB
testcase_01 AC 129 ms
57,576 KB
testcase_02 AC 121 ms
56,804 KB
testcase_03 AC 137 ms
58,088 KB
testcase_04 AC 132 ms
57,828 KB
testcase_05 AC 248 ms
61,088 KB
testcase_06 AC 248 ms
60,804 KB
testcase_07 AC 243 ms
60,644 KB
testcase_08 AC 261 ms
60,836 KB
testcase_09 AC 243 ms
61,036 KB
testcase_10 AC 404 ms
62,904 KB
testcase_11 AC 423 ms
62,604 KB
testcase_12 AC 445 ms
63,024 KB
testcase_13 AC 422 ms
62,976 KB
testcase_14 AC 425 ms
62,888 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 134 ms
57,796 KB
testcase_19 AC 133 ms
57,828 KB
testcase_20 AC 130 ms
57,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] rui = new long[n];
    long[] a = new long[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
      if(i == 0) {
        rui[i] = a[i];
      } else {
        rui[i] = rui[i - 1] + a[i];
      }
    }
    long[] kukan = new long[n - 23];
    for(int i = 0; i < n - 23; i++) {
      if(i == 0) {
        kukan[i] = rui[i + 23]; 
      } else {
        kukan[i] = rui[i + 23] - rui[i - 1];
      }  
    }
    long ans = 0;
    for(int i = 0; i < n - 23; i++) {
      ans = Math.max(ans, kukan[i]);
    }
    int q = sc.nextInt();
    for(int i = 0; i < q; i++) {
      int t = sc.nextInt() - 1;
      long v = sc.nextLong();
      long sa = v - a[t];
      a[t] = v;
      for(int j = t - 23; j <= t; j++) {
        if((j >= 0) && (j < n - 23)) {
          kukan[j] = kukan[j] + sa;
          ans = Math.max(ans, kukan[j]);
        } 
      }
      System.out.println(ans);
    }
  }
}
0