結果

問題 No.1375 Divide and Update
ユーザー seiyuseiyu
提出日時 2021-02-08 01:07:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,200 bytes
コンパイル時間 1,776 ms
コンパイル使用メモリ 170,072 KB
実行使用メモリ 12,824 KB
最終ジャッジ日時 2023-09-18 03:11:25
合計ジャッジ時間 6,473 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 226 ms
10,428 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 278 ms
12,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

__attribute__ ((constructor))
void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

int main(){
    int n;
    ll x, y;
    cin >> n >> x >> y;

    vector<ll> a(n);
    vector<ll> a_rev;
    vector<ll> sum_x(n + 1, 0);
    vector<ll> sum_y(n + 1, 0);
    vector<ll> ans_x(n);
    vector<ll> ans_y(n);

    rep(i, n) cin >> a[i];

    reverse(a.begin(), a.end());

    a_rev = a;

    reverse(a.begin(), a.end());


    rep(i, n) { sum_x[i + 1] = sum_x[i] + x - a[i]; }
    rep(i, n) { sum_y[i + 1] = sum_y[i] + y - a_rev[i]; }

    ll min_x , max_x;
    ll min_y, max_y;

    rep(i,n){
        // cout << min_x << " " << max_x << endl;
        // cout << min_y << " " << max_y << endl;
        // cout << "-----------------------" << endl;
        if(i == 0){
            ans_x[i] = sum_x[i + 1];
            ans_y[i] = sum_y[i + 1];
            min_x = min(sum_x[i], sum_x[i+1]);
            max_x = max(sum_x[i], sum_x[i+1]);
            min_y = min(sum_y[i], sum_y[i+1]);
            max_y = max(sum_y[i], sum_y[i+1]);
        }else{
            chmax(max_x, sum_x[i + 1]);
            chmax(max_y, sum_y[i + 1]);
            ans_x[i] = max_x - min_x;
            ans_y[i] = max_y - min_y;
            chmin(min_x, sum_x[i + 1]);
            chmin(min_y, sum_y[i + 1]);
        }
    }

    ll all_sum = accumulate(a.begin(), a.end(), 0ll);

    FOR(i,1,n-1){
        ll pre = all_sum;
        all_sum += ans_x[i - 1];
        all_sum += ans_y[n - i - 2];
        cout << all_sum << endl;
        // cout << "--------------------------" << endl;
        all_sum = pre;
    }

    return 0;
}
0