結果

問題 No.999 てん vs. ほむ
ユーザー ForestedForested
提出日時 2020-05-26 12:13:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 1,099 ms
コンパイル使用メモリ 95,968 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-21 04:13:24
合計ジャッジ時間 3,336 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,948 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 5 ms
6,940 KB
testcase_09 AC 72 ms
6,944 KB
testcase_10 AC 25 ms
6,944 KB
testcase_11 AC 17 ms
6,940 KB
testcase_12 AC 33 ms
6,940 KB
testcase_13 AC 80 ms
6,940 KB
testcase_14 AC 80 ms
6,940 KB
testcase_15 AC 82 ms
6,944 KB
testcase_16 AC 82 ms
6,944 KB
testcase_17 AC 53 ms
6,944 KB
testcase_18 AC 53 ms
6,940 KB
testcase_19 AC 52 ms
6,940 KB
testcase_20 AC 53 ms
6,944 KB
testcase_21 AC 75 ms
6,944 KB
testcase_22 AC 73 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        A[i] = a - b;
    }
    vector<long long> sum(N + 1, 0);
    rep(i, N) sum[i + 1] = sum[i] + A[i];
    long long ans = -1e18;
    rep(i, N + 1) ans = max(ans, sum[i] - (sum[N] - sum[i]));
    cout << ans << endl;
    return 0;
}
0