結果

問題 No.999 てん vs. ほむ
ユーザー kcvlexkcvlex
提出日時 2020-02-28 21:29:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,262 bytes
コンパイル時間 1,716 ms
コンパイル使用メモリ 165,112 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2024-04-21 17:53:10
合計ジャッジ時間 3,296 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 WA -
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 29 ms
7,424 KB
testcase_10 AC 10 ms
6,940 KB
testcase_11 AC 8 ms
6,940 KB
testcase_12 AC 15 ms
6,940 KB
testcase_13 AC 31 ms
8,064 KB
testcase_14 AC 32 ms
7,808 KB
testcase_15 AC 31 ms
7,936 KB
testcase_16 AC 32 ms
7,936 KB
testcase_17 AC 23 ms
7,680 KB
testcase_18 WA -
testcase_19 AC 22 ms
7,552 KB
testcase_20 WA -
testcase_21 AC 31 ms
7,808 KB
testcase_22 AC 30 ms
7,680 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