結果

問題 No.999 てん vs. ほむ
ユーザー ferinferin
提出日時 2020-02-28 21:29:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 1,013 bytes
コンパイル時間 2,514 ms
コンパイル使用メモリ 195,776 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 17:51:50
合計ジャッジ時間 3,839 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 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,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 30 ms
6,944 KB
testcase_10 AC 11 ms
6,944 KB
testcase_11 AC 8 ms
6,940 KB
testcase_12 AC 14 ms
6,940 KB
testcase_13 AC 32 ms
6,940 KB
testcase_14 AC 32 ms
6,940 KB
testcase_15 AC 34 ms
6,940 KB
testcase_16 AC 32 ms
6,944 KB
testcase_17 AC 23 ms
6,940 KB
testcase_18 AC 22 ms
6,940 KB
testcase_19 AC 23 ms
6,944 KB
testcase_20 AC 25 ms
6,940 KB
testcase_21 AC 31 ms
6,944 KB
testcase_22 AC 30 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(2*n);
    REP(i, 2*n) cin >> a[i];

    vector<ll> vl(n);
    REP(i, n) vl[i] = (i==0?0:vl[i-1]) + a[2*i] - a[2*i+1];
    vector<ll> vr(n);
    for(ll i=n-1; i>=0; --i) vr[i] = (i==n-1?0:vr[i+1]) + a[2*i+1] - a[2*i];
    dump(vl);
    dump(vr);

    ll ret = -INF;
    chmax(ret, vl[n-1]);
    chmax(ret, vr[0]);
    REP(i, n-1) chmax(ret, vl[i] + vr[i+1]); 
    cout << ret << endl;

    return 0;
}
0