結果

問題 No.999 てん vs. ほむ
ユーザー rogi52rogi52
提出日時 2020-11-24 02:39:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 453 bytes
コンパイル時間 1,522 ms
コンパイル使用メモリ 168,104 KB
実行使用メモリ 4,852 KB
最終ジャッジ日時 2023-10-01 00:44:24
合計ジャッジ時間 4,029 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 24 ms
4,528 KB
testcase_10 AC 9 ms
4,380 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 12 ms
4,380 KB
testcase_13 AC 27 ms
4,692 KB
testcase_14 AC 27 ms
4,744 KB
testcase_15 AC 27 ms
4,740 KB
testcase_16 AC 27 ms
4,852 KB
testcase_17 AC 19 ms
4,536 KB
testcase_18 WA -
testcase_19 AC 19 ms
4,540 KB
testcase_20 WA -
testcase_21 AC 26 ms
4,540 KB
testcase_22 AC 26 ms
4,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

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

    int N; cin >> N;
    vector<ll> D;
    rep(i,N){
        ll a,b; cin >> a >> b;
        D.emplace_back(a - b);
    }

    vector<ll> S(N+1,0);
    rep(i,N) S[i+1] = S[i] + D[i];

    ll ans = -1e18;
    rep(i,N) ans = max(ans, S[i] - (S[N] - S[i]));
    cout << ans << endl;
}
0