結果

問題 No.1687 What the Heck?
ユーザー 👑 tamatotamato
提出日時 2021-09-24 21:26:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 382 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,500 KB
実行使用メモリ 111,016 KB
最終ジャッジ日時 2023-09-18 20:37:43
合計ジャッジ時間 3,520 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,960 KB
testcase_01 AC 74 ms
71,960 KB
testcase_02 AC 74 ms
71,612 KB
testcase_03 AC 75 ms
71,812 KB
testcase_04 AC 75 ms
71,820 KB
testcase_05 AC 75 ms
71,840 KB
testcase_06 AC 74 ms
71,744 KB
testcase_07 AC 105 ms
95,324 KB
testcase_08 AC 118 ms
104,664 KB
testcase_09 AC 104 ms
95,244 KB
testcase_10 AC 96 ms
88,956 KB
testcase_11 AC 95 ms
89,236 KB
testcase_12 AC 161 ms
110,956 KB
testcase_13 AC 160 ms
110,880 KB
testcase_14 AC 161 ms
110,944 KB
testcase_15 AC 159 ms
110,796 KB
testcase_16 AC 159 ms
109,840 KB
testcase_17 AC 83 ms
77,888 KB
testcase_18 AC 165 ms
111,016 KB
testcase_19 AC 79 ms
76,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    P = list(map(int, input().split()))

    idx = {p: i+1 for i, p in enumerate(P)}
    ans = 0
    cur = N * (N+1) // 2
    for p in range(N, 0, -1):
        ans = max(ans, cur - idx[p] * 2)
        cur -= idx[p]
    print(ans)


if __name__ == '__main__':
    main()
0