結果

問題 No.999 てん vs. ほむ
ユーザー Ricky_ponRicky_pon
提出日時 2020-02-28 21:56:05
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 1,352 bytes
コンパイル時間 1,510 ms
コンパイル使用メモリ 163,528 KB
実行使用メモリ 6,940 KB
最終ジャッジ日時 2024-04-21 18:26:09
合計ジャッジ時間 2,891 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 27 ms
6,656 KB
testcase_10 AC 9 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 AC 13 ms
5,376 KB
testcase_13 AC 29 ms
6,912 KB
testcase_14 AC 28 ms
6,784 KB
testcase_15 AC 30 ms
6,912 KB
testcase_16 AC 29 ms
6,940 KB
testcase_17 AC 21 ms
6,784 KB
testcase_18 AC 22 ms
6,528 KB
testcase_19 AC 22 ms
6,784 KB
testcase_20 AC 21 ms
6,784 KB
testcase_21 AC 28 ms
6,784 KB
testcase_22 AC 26 ms
6,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n;
    scanf("%d", &n);
    lint a[2*n], L[n+1], R[n+1];
    L[0] = R[0] = 0;
    rep(i, 2*n){
        scanf("%lld", &a[i]);
        if(i % 2 == 0) L[i/2+1] = a[i];
        else R[i/2+1] = a[i];
    }
    partial_sum(L, L+n+1, L);
    partial_sum(R, R+n+1, R);
    lint ans = -INF;
    rep(i, n+1){
        chmax(ans, L[i] + R[n]-R[i]);
    }
    printf("%lld\n", 2*ans - (L[n]+R[n]));
}
0