結果

問題 No.865 24時間降水量
ユーザー kyunakyuna
提出日時 2019-08-20 22:23:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 421 ms / 2,000 ms
コード長 770 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 72,448 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 04:27:09
合計ジャッジ時間 3,494 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 21 ms
5,376 KB
testcase_11 AC 20 ms
5,376 KB
testcase_12 AC 21 ms
5,376 KB
testcase_13 AC 20 ms
5,376 KB
testcase_14 AC 20 ms
5,376 KB
testcase_15 AC 421 ms
5,376 KB
testcase_16 AC 417 ms
5,376 KB
testcase_17 AC 419 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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