結果

問題 No.865 24時間降水量
ユーザー mine691mine691
提出日時 2019-08-17 00:08:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 418 ms / 2,000 ms
コード長 797 bytes
コンパイル時間 1,506 ms
コンパイル使用メモリ 169,504 KB
実行使用メモリ 6,480 KB
最終ジャッジ日時 2023-10-24 12:31:28
合計ジャッジ時間 3,855 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, Q;
ll mx;

int main()
{
    cin >> N;
    vector<ll> a(N), rain(N - 23);
    for (int i = 0; i < N; i++)
        cin >> a[i];

    for (int i = 0; i + 23 < N; i++)
    {
        for (int j = 0; j < 24; j++)
        {
            rain[i] += a[i + j];
        }
        mx = max(mx, rain[i]);
    }

    cin >> Q;

    for (int i = 0; i < Q; i++)
    {
        int t;
        ll v;
        cin >> t >> v;
        t--;

        for (int j = max(0, t - 23); j <= min(t, N - 24); j++)
        {
            rain[j] += v - a[t];
            mx = max(mx, rain[j]);
        }
        
        a[t] = v;

        cout << mx << endl;
    }
}
0