結果

問題 No.999 てん vs. ほむ
ユーザー rjkurorjkuro
提出日時 2020-02-28 22:10:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,529 bytes
コンパイル時間 1,009 ms
コンパイル使用メモリ 110,972 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 19:02:52
合計ジャッジ時間 2,860 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 24 ms
5,376 KB
testcase_11 AC 17 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 83 ms
5,376 KB
testcase_14 AC 84 ms
5,376 KB
testcase_15 AC 82 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 51 ms
5,376 KB
testcase_18 AC 48 ms
5,376 KB
testcase_19 AC 51 ms
5,376 KB
testcase_20 AC 51 ms
5,376 KB
testcase_21 AC 77 ms
5,376 KB
testcase_22 AC 76 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll power(ll x, ll y) {
    ll ret = 1;
    while(y-- > 0) ret *= x;
    return ret;
}

ll gcd(ll a, ll b) {
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll extgcd(ll a, ll b, ll& x, ll& y) {
    x = 1; y = 0;
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    ll X, Y;
    auto d = extgcd(b, a % b, X, Y);
    x = Y;
    y = X - (a / b) * Y;
    return d;
}

int run(istream& in, ostream& out) {
    ll N;
    in >> N;
    vector<ll> v(2*N);
    ll a=0, b = 0;
    REP(i, N) {
        in >> v[2*i];
        in >> v[2*i+1];
        a+= v[2*i];
        b+= v[2*i+1];
    }
    ll total = a - b;
    ll ans = total;
    REP(i, N) {
        total -= 2*(v[2*i] - v[2*i+1]);
        ans = max(ans, abs(total));
    }
    out << ans << endl;
    return 0;
}


int main() {
    return run(cin, cout);
}

0