結果

問題 No.865 24時間降水量
ユーザー kyuna
提出日時 2019-08-20 22:23:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 385 ms / 2,000 ms
コード長 770 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 71,936 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-06 16:11:51
合計ジャッジ時間 3,175 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int &ai: a) cin >> ai;
    vector<int> sum(n - 23);    // sum[i] = a[i] + .. + a[i + 23]
    for (int i = 0; i < 24; i++) sum[0] += a[i];
    for (int i = 1; i < n - 23; i++) sum[i] = sum[i - 1] - a[i - 1] + a[i + 23];
    int ma = *max_element(sum.begin(), sum.end());
    int q; cin >> q;
    while (q--) {
        int t, v; cin >> t >> v; t--;
        int d = v - a[t]; a[t] = v;
        for (int i = 0; i < 24; i++) {
            if (t + i - 23 < 0 || t + i - 23 >= n - 23) continue;
            sum[t + i - 23] += d;
            ma = max(ma, sum[t + i - 23]);
        }
        cout << ma << endl;
    }
    return 0;
}
0