結果

問題 No.1687 What the Heck?
ユーザー kokatsukokatsu
提出日時 2021-09-24 23:05:49
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 381 bytes
コンパイル時間 3,367 ms
コンパイル使用メモリ 218,396 KB
実行使用メモリ 15,024 KB
最終ジャッジ日時 2023-09-04 14:14:57
合計ジャッジ時間 3,951 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 24 ms
7,148 KB
testcase_08 AC 33 ms
8,892 KB
testcase_09 AC 24 ms
7,436 KB
testcase_10 AC 17 ms
5,180 KB
testcase_11 AC 18 ms
7,072 KB
testcase_12 AC 73 ms
14,700 KB
testcase_13 AC 74 ms
13,004 KB
testcase_14 AC 73 ms
14,428 KB
testcase_15 AC 73 ms
14,448 KB
testcase_16 AC 71 ms
13,296 KB
testcase_17 AC 6 ms
4,380 KB
testcase_18 AC 74 ms
15,024 KB
testcase_19 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

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

    auto P = readln.chomp.split.to!(long[]);
    auto R = iota(1L, N+1).array;
    
    zip(P, R).sort!"a[0] > b[0]";

    long ttl = N * (N + 1) / 2;
    long res;
    foreach (r; R) {
        long tmp = ttl - 2 * r;
        if (res < tmp) {
            res = tmp;
        }
        ttl -= r;
    }

    res.writeln;
}
0