結果

問題 No.1687 What the Heck?
ユーザー kokatsu
提出日時 2021-09-24 22:31:51
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 378 bytes
コンパイル時間 2,283 ms
コンパイル使用メモリ 209,860 KB
実行使用メモリ 11,308 KB
最終ジャッジ日時 2024-06-22 12:36:56
合計ジャッジ時間 3,476 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 8 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

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

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

    long res;

    long tmp = N * (N - 1) / 2 - P.maxIndex - 1;
    if (res < tmp) {
        res = tmp;
    }

    foreach (i; 0 .. N) {
        tmp = P[i] * (P[i] + 1) / 2 - 2 * (i + 1);
        if (res < tmp) {
            res = tmp;
        }
    }

    res.writeln;
}
0