結果
| 問題 |
No.865 24時間降水量
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-16 22:17:50 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 78 ms / 2,000 ms |
| コード長 | 973 bytes |
| コンパイル時間 | 695 ms |
| コンパイル使用メモリ | 129,300 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 14:31:39 |
| 合計ジャッジ時間 | 1,891 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#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;
}