結果

問題 No.999 てん vs. ほむ
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-02-28 21:50:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 1,634 ms
コンパイル使用メモリ 159,968 KB
実行使用メモリ 5,760 KB
最終ジャッジ日時 2024-04-21 18:19:49
合計ジャッジ時間 3,202 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 65 ms
5,376 KB
testcase_10 AC 21 ms
5,376 KB
testcase_11 AC 14 ms
5,376 KB
testcase_12 AC 31 ms
5,376 KB
testcase_13 AC 72 ms
5,504 KB
testcase_14 AC 73 ms
5,760 KB
testcase_15 AC 75 ms
5,632 KB
testcase_16 AC 74 ms
5,632 KB
testcase_17 AC 50 ms
5,504 KB
testcase_18 AC 46 ms
5,376 KB
testcase_19 AC 47 ms
5,376 KB
testcase_20 AC 48 ms
5,376 KB
testcase_21 AC 72 ms
5,504 KB
testcase_22 AC 74 ms
5,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    ll ans = 0;
    vector<ll> v(n), a(n + 1, 0), b(n + 1, 0);
    for (int i = 0; i < n; i++) {
        int x, y; cin >> x >> y;
        v[i] = x - y;
    }
    for (int i = 0; i < n; i++) {
        a[i + 1] = v[i] + a[i];
        b[n - i - 1] = -v[n - i - 1] + b[n - i];
    }
    for (int i = 0; i <= n; i++) {
        ans = max(ans, a[i] + b[i]);
    }
    cout << ans << endl;
    return 0;
}
0