結果

問題 No.1375 Divide and Update
ユーザー hiro71687khiro71687k
提出日時 2023-04-15 16:30:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 392 ms / 2,000 ms
コード長 830 bytes
コンパイル時間 3,866 ms
コンパイル使用メモリ 256,248 KB
実行使用メモリ 16,332 KB
最終ジャッジ日時 2024-04-19 10:18:48
合計ジャッジ時間 9,486 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 310 ms
15,496 KB
testcase_11 AC 283 ms
15,204 KB
testcase_12 AC 164 ms
9,344 KB
testcase_13 AC 144 ms
9,216 KB
testcase_14 AC 349 ms
16,332 KB
testcase_15 AC 362 ms
16,096 KB
testcase_16 AC 392 ms
16,324 KB
testcase_17 AC 370 ms
16,164 KB
testcase_18 AC 362 ms
16,092 KB
testcase_19 AC 368 ms
16,092 KB
testcase_20 AC 331 ms
16,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=144499999999994;
ll mod=1000000007;
ll op(ll a,ll b){
    return max(a,b);
}
ll e(){
    return -inf;
}
int main(){
    ll n,x,y;
    cin >> n >> x >> y;
    vector<ll>a(n);
    ll sum=0;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        sum+=a[i];
    }
    vector<ll>b(n),c(n);
    ll now=0;
    for (ll i = 0; i < n; i++)
    {
        b[i]=x-a[i]+now;
        now=max((ll)0,b[i]);
    }
    now=0;
    for (ll i = n-1; i >=0; i--)
    {
        c[i]=y-a[i]+now;
        now=max((ll)0,c[i]);
    }
    segtree<ll,op,e>seg1(b),seg2(c);
    for (ll i = 1; i < n-1; i++)
    {
        cout << seg1.prod(0,i)+seg2.prod(i+1,n)+sum << endl;
    }
}
0