結果

問題 No.999 てん vs. ほむ
ユーザー kokatsukokatsu
提出日時 2021-11-15 21:54:48
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 1,785 ms
コンパイル使用メモリ 204,096 KB
実行使用メモリ 13,324 KB
最終ジャッジ日時 2023-09-04 14:59:04
合計ジャッジ時間 4,615 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 36 ms
11,900 KB
testcase_10 AC 13 ms
7,184 KB
testcase_11 AC 9 ms
4,848 KB
testcase_12 AC 18 ms
7,784 KB
testcase_13 AC 42 ms
13,256 KB
testcase_14 AC 42 ms
13,324 KB
testcase_15 AC 42 ms
13,264 KB
testcase_16 AC 41 ms
13,324 KB
testcase_17 AC 27 ms
12,000 KB
testcase_18 AC 27 ms
11,636 KB
testcase_19 AC 28 ms
11,612 KB
testcase_20 AC 27 ms
11,756 KB
testcase_21 AC 40 ms
13,180 KB
testcase_22 AC 38 ms
12,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    int N;
    readf("%d\n", N);

    auto A = readln.chomp.split.to!(long[]);

    auto odd = new long[](N+1), even = new long[](N+1);
    foreach (i; 0 .. N) {
        odd[i+1] = odd[i] + A[2*i];
        even[i+1] = even[i] + A[2*i+1];
    }

    long res;
    foreach (i; 0 .. N+1) {
        res = max(res, (odd[i]-even[i])*2-odd[N]+even[N]);
    }

    res.writeln;
}
0