結果

問題 No.999 てん vs. ほむ
ユーザー ゆきのんゆきのん
提出日時 2020-02-28 21:34:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 1,201 bytes
コンパイル時間 1,780 ms
コンパイル使用メモリ 166,540 KB
実行使用メモリ 8,176 KB
最終ジャッジ日時 2024-04-21 18:03:10
合計ジャッジ時間 4,080 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 5 ms
5,376 KB
testcase_09 AC 80 ms
7,784 KB
testcase_10 AC 25 ms
5,376 KB
testcase_11 AC 18 ms
5,376 KB
testcase_12 AC 36 ms
5,376 KB
testcase_13 AC 89 ms
8,172 KB
testcase_14 AC 89 ms
8,176 KB
testcase_15 AC 90 ms
8,048 KB
testcase_16 AC 88 ms
7,920 KB
testcase_17 AC 59 ms
7,676 KB
testcase_18 AC 55 ms
7,776 KB
testcase_19 AC 59 ms
7,672 KB
testcase_20 AC 60 ms
7,808 KB
testcase_21 AC 86 ms
7,896 KB
testcase_22 AC 82 ms
7,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



int main(){
    int n;cin >> n;
    vector<LL> a(2*n);
    for (int i = 0; i < 2*n; i++) {
        cin >> a[i];
    }
    vector<LL> l,r;
    for (int i = 0; i < 2*n; i+=2) {
        l.pb(a[i] - a[i+1]);
        r.pb(a[i+1] - a[i]);
    }
    vector<LL> cl(n+1,0),cr(n+1,0);
    for (int i = 0; i < n; i++) {
        cl[i+1] = cl[i] + l[i];
    }
    for (int i = n; i >= 1; i--) {
        cr[i-1] = cr[i] + r[i-1];
    }
    LL ans = -LINF;
    for (int i = 0; i <= n; i++) {
        chmax(ans, cl[i] + cr[i]);
    }
    cout << ans << endl;
    return 0;
}
0