結果

問題 No.865 24時間降水量
ユーザー 37zigen37zigen
提出日時 2019-08-17 00:48:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 416 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 64,756 KB
実行使用メモリ 6,120 KB
最終ジャッジ日時 2023-10-24 14:22:20
合計ジャッジ時間 3,109 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,120 KB
testcase_01 AC 4 ms
6,120 KB
testcase_02 AC 3 ms
6,120 KB
testcase_03 AC 3 ms
6,120 KB
testcase_04 AC 3 ms
6,120 KB
testcase_05 AC 6 ms
6,120 KB
testcase_06 AC 5 ms
6,120 KB
testcase_07 AC 6 ms
6,120 KB
testcase_08 AC 5 ms
6,120 KB
testcase_09 AC 5 ms
6,120 KB
testcase_10 AC 21 ms
6,120 KB
testcase_11 AC 21 ms
6,120 KB
testcase_12 AC 21 ms
6,120 KB
testcase_13 AC 21 ms
6,120 KB
testcase_14 AC 21 ms
6,120 KB
testcase_15 AC 414 ms
6,120 KB
testcase_16 AC 416 ms
6,120 KB
testcase_17 AC 414 ms
6,120 KB
testcase_18 AC 4 ms
6,120 KB
testcase_19 AC 3 ms
6,120 KB
testcase_20 AC 3 ms
6,120 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:12:10: warning: iteration 212345 invokes undefined behavior [-Waggressive-loop-optimizations]
   12 |     a[i] = 0;
      |     ~~~~~^~~
main.cpp:11:21: note: within this loop
   11 |   for (int i = 0; i <= N; ++i){
      |                   ~~^~~~
main.cpp:12:10: warning: 'void* __builtin_memset(void*, int, long unsigned int)' writing 849384 bytes into a region of size 849380 overflows the destination [-Wstringop-overflow=]
   12 |     a[i] = 0;
      |     ~~~~~^~~
main.cpp:4:5: note: destination object 'a' of size 849380
    4 | int a[N];
      |     ^
main.cpp:13:12: warning: 'void* __builtin_memset(void*, int, long unsigned int)' writing 1698768 bytes into a region of size 1698760 overflows the destination [-Wstringop-overflow=]
   13 |     sum[i] = 0;
      |     ~~~~~~~^~~
main.cpp:5:11: note: destination object 'sum' of size 1698760
    5 | long long sum[N];
      |           ^~~

ソースコード

diff #

#include <iostream>

const int N = 212345;
int a[N];
long long sum[N];

int main() {
  int n;
  int q;
  std::cin >> n;
  for (int i = 0; i <= N; ++i){
    a[i] = 0;
    sum[i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  long long ma = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 24; ++j) {
      sum[i] += a[i + j];
      ma = std::max(ma, sum[i]);
    }
  }
  std::cin >> q;
  for(int i = 0; i < q; ++i) {
    int t, v;
    std::cin >> t;
    std::cin >> v;
    --t;
    for (int j = std::max(0, t - 23); j <= t; ++j) {
      sum[j] += v - a[t];
      ma = std::max(ma, sum[j]);
    }
    std::cout << ma << std::endl;
    a[t] = v;
  }
}
0