結果
問題 | No.865 24時間降水量 |
ユーザー |
|
提出日時 | 2019-08-16 22:17:50 |
言語 | C++17(clang Beta) (clang 13.0.0 + boost 1.78.0) |
結果 |
AC
|
実行時間 | 80 ms / 2,000 ms |
コード長 | 973 bytes |
コンパイル時間 | 488 ms |
使用メモリ | 4,732 KB |
最終ジャッジ日時 | 2023-01-06 19:28:18 |
合計ジャッジ時間 | 1,824 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge16 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
3,580 KB |
testcase_01 | AC | 2 ms
3,580 KB |
testcase_02 | AC | 1 ms
3,584 KB |
testcase_03 | AC | 2 ms
3,580 KB |
testcase_04 | AC | 1 ms
3,440 KB |
testcase_05 | AC | 2 ms
3,608 KB |
testcase_06 | AC | 1 ms
3,672 KB |
testcase_07 | AC | 1 ms
3,560 KB |
testcase_08 | AC | 2 ms
3,504 KB |
testcase_09 | AC | 1 ms
3,576 KB |
testcase_10 | AC | 4 ms
3,448 KB |
testcase_11 | AC | 5 ms
3,588 KB |
testcase_12 | AC | 4 ms
3,508 KB |
testcase_13 | AC | 4 ms
3,516 KB |
testcase_14 | AC | 5 ms
3,588 KB |
testcase_15 | AC | 79 ms
4,676 KB |
testcase_16 | AC | 79 ms
4,672 KB |
testcase_17 | AC | 80 ms
4,732 KB |
testcase_18 | AC | 1 ms
3,496 KB |
testcase_19 | AC | 2 ms
3,588 KB |
testcase_20 | AC | 2 ms
3,484 KB |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #define REP(i, n) for(int (i) = 0; (i) < (n); ++(i)) #define ALL(TheArray) TheArray.begin(), TheArray.end() template <class T> inline T& chmax(T& a, T b){return (a < b) ? a = b : a;} template <class T> inline T& chmin(T& a, T b){return (a > b) ? a = b : a;} using lli = long long int; std::vector<int> A, S; int main(void){ int n; scanf("%d", &n); A.resize(n); REP(i, n) scanf("%d", &A[i]); S.resize(n-23); int s = 0; REP(i, 24) s += A[i]; REP(i, n-23){ S[i] = s; if(i + 24 < n) s += A[i+24] - A[i]; } int mx = -1; REP(i, n - 23) if(mx < S[i]) mx = S[i]; int Q; scanf("%d", &Q); while(Q--){ int t, v; scanf("%d%d", &t, &v); t--; int diff = v - A[t]; A[t] = v; REP(j, 24) if(0 <= t - j and t - j < n - 23){ S[t-j] += diff; chmax(mx, S[t-j]); } printf("%d\n", mx); } return 0; }