結果

問題 No.999 てん vs. ほむ
ユーザー mikianaaamikianaaa
提出日時 2020-08-31 21:23:40
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 728 bytes
コンパイル時間 1,465 ms
コンパイル使用メモリ 165,524 KB
実行使用メモリ 4,824 KB
最終ジャッジ日時 2023-08-10 17:46:38
合計ジャッジ時間 3,133 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 23 ms
4,388 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 11 ms
4,376 KB
testcase_13 AC 26 ms
4,520 KB
testcase_14 AC 25 ms
4,508 KB
testcase_15 AC 25 ms
4,676 KB
testcase_16 AC 25 ms
4,668 KB
testcase_17 AC 17 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 17 ms
4,668 KB
testcase_20 WA -
testcase_21 AC 25 ms
4,672 KB
testcase_22 AC 24 ms
4,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<ll> left(N + 1, 0), right(N + 1, 0);
    ll sum = 0;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        sum += (a + b);
        left[i + 1] = a;
        right[N - i] = b;
    }

    rep(i, N) {
        left[i + 1] += left[i];
        right[i + 1] += right[i];
    }

    ll homura = 0, tenpura = 0;

    rep(i, N) { homura = max(homura, left[i] + right[N - i]); }

    cout << 2 * homura - sum << endl;
}
0