結果

問題 No.1375 Divide and Update
コンテスト
ユーザー hiro71687k
提出日時 2023-04-15 16:30:15
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 821 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,014 ms
コンパイル使用メモリ 275,420 KB
実行使用メモリ 16,384 KB
最終ジャッジ日時 2026-06-30 08:30:08
合計ジャッジ時間 7,948 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 3 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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=144494;
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