結果

問題 No.999 てん vs. ほむ
ユーザー kcvlexkcvlex
提出日時 2020-02-28 21:31:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 2,263 bytes
コンパイル時間 1,509 ms
コンパイル使用メモリ 166,220 KB
実行使用メモリ 7,944 KB
最終ジャッジ日時 2023-08-03 19:39:43
合計ジャッジ時間 3,053 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 26 ms
7,256 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 12 ms
4,812 KB
testcase_13 AC 28 ms
7,804 KB
testcase_14 AC 27 ms
7,944 KB
testcase_15 AC 27 ms
7,744 KB
testcase_16 AC 27 ms
7,712 KB
testcase_17 AC 20 ms
7,212 KB
testcase_18 AC 19 ms
7,192 KB
testcase_19 AC 20 ms
7,256 KB
testcase_20 AC 20 ms
7,476 KB
testcase_21 AC 26 ms
7,796 KB
testcase_22 AC 26 ms
7,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return vec<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec

#ifdef DEBUGGING
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

using namespace std;

int main() {
    ll n;
    cin >> n;
    vec<ll> a(2 * n);
    for (auto &&e : a) cin >> e;
    ll sum = accumulate(ALL(a), 0ll);
    vec<ll> sumo(2 * n + 1), sume(2 * n + 1);
    for (ll i = 0; i < 2 * n; i++) {
        sumo[i + 1] = sumo[i] + (i & 1 ? a[i] : 0);
        sume[i + 1] = sume[i] + (i & 1 ? 0 : a[i]);
    }
    ll ans = -5e15;
    for (ll i = 0; i <= n; i++) {
        ll hom = sume[2 * i] + (sumo.back() - sumo[2 * i]);
        ll tem = sum - hom;
        chmax(ans, hom - tem);
    }
    cout << ans << endl;
    return 0;
}
0