結果

問題 No.1375 Divide and Update
ユーザー Ricky_ponRicky_pon
提出日時 2021-02-05 22:24:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,736 bytes
コンパイル時間 1,963 ms
コンパイル使用メモリ 202,516 KB
実行使用メモリ 9,544 KB
最終ジャッジ日時 2023-09-15 08:50:18
合計ジャッジ時間 4,969 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
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 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

vector<lint> solve(vector<lint> a, lint x) {
    int n = a.size();
    rep(i, n) a[i] = x - a[i];
    rep(i, n) printf("%lld ", a[i]);
    printf("\n");
    vector<lint> v(n - 2);
    lint lsum = 0, sum = 0;
    rep(i, n - 2) {
        sum += a[i];
        v[i] = sum - lsum;
        if (i >= 1) chmax(v[i], v[i - 1]);
        chmin(lsum, sum);
    }
    return v;
}

int main() {
    int n;
    lint x, y;
    scanf("%d%lld%lld", &n, &x, &y);
    vector<lint> a(n);
    rep(i, n) scanf("%lld", &a[i]);

    auto v = solve(a, x);
    reverse(a.begin(), a.end());
    auto w = solve(a, y);
    reverse(w.begin(), w.end());
    lint sum = accumulate(a.begin(), a.end(), 0LL);
    rep(i, n - 2) printf("%lld\n", v[i] + w[i] + sum);
}
0