結果

問題 No.999 てん vs. ほむ
ユーザー UtopiosphereUtopiosphere
提出日時 2020-02-28 21:43:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,014 bytes
コンパイル時間 1,661 ms
コンパイル使用メモリ 166,808 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-04-21 18:12:53
合計ジャッジ時間 3,626 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 WA -
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 5 ms
6,940 KB
testcase_09 AC 79 ms
6,944 KB
testcase_10 AC 25 ms
6,944 KB
testcase_11 AC 16 ms
6,940 KB
testcase_12 AC 35 ms
6,944 KB
testcase_13 AC 89 ms
7,296 KB
testcase_14 AC 88 ms
7,168 KB
testcase_15 AC 87 ms
7,168 KB
testcase_16 AC 86 ms
7,168 KB
testcase_17 AC 57 ms
6,944 KB
testcase_18 WA -
testcase_19 AC 58 ms
6,940 KB
testcase_20 WA -
testcase_21 AC 88 ms
7,168 KB
testcase_22 AC 85 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, ans = -10000000000000000;
    cin >> N;
    vector<int64_t> A(2 * N), B(N), left(N), right(N);
    for (int i = 0; i < 2 * N; i++){
        cin >> A.at(i);
    }
    for (int i = 0; i < N; i++){
        B.at(i) = A.at(2 * i) - A.at(2 * i + 1);
    }
    for (int i = 0; i < N; i++){
        if (i == 0){
            left.at(i) = B.at(i);
            continue;
        }
        left.at(i) = left.at(i - 1) + B.at(i);
    }
    for (int i = 0; i < N; i++){
        if (i == 0){
            right.at(N - i - 1) = B.at(N - i - 1) * (-1);
            continue;
        }
        right.at(N - i - 1) = right.at(N - i) - B.at(N - i - 1);
    }
    for (int i = 0; i < N - 1; i++){
        ans = max(ans, right.at(i + 1) + left.at(i));
    }
    ans = max(ans, right.at(0));

    cout << ans << endl;

}
0