結果

問題 No.999 てん vs. ほむ
ユーザー aaaaaa
提出日時 2020-03-30 12:35:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 2,184 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 92,888 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 12:49:42
合計ジャッジ時間 2,557 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

ll a[100005];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    ios::sync_with_stdio(0);
    cin.tie(0);

    ll x, y;
    FOR(i, 1, N + 1) {
        cin >> x >> y;
        a[i] = x - y;
    }

    ll sum = 0;
    FOR(i, 1, N + 1) sum += a[i];

    ll ans = sum;
    for (ll i = N; i >= 1; i--) {
        sum -= 2 * a[i];
        ans = max(ans, sum);
    }
    cout << ans << endl;

    return 0;
}
0