結果

問題 No.1687 What the Heck?
ユーザー TomoyarnTomoyarn
提出日時 2022-01-01 21:30:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 493 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 101,504 KB
最終ジャッジ日時 2024-04-18 21:39:41
合計ジャッジ時間 2,334 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,584 KB
testcase_01 AC 39 ms
51,712 KB
testcase_02 AC 40 ms
51,456 KB
testcase_03 AC 37 ms
51,712 KB
testcase_04 AC 39 ms
51,840 KB
testcase_05 AC 40 ms
51,584 KB
testcase_06 WA -
testcase_07 AC 57 ms
72,576 KB
testcase_08 AC 57 ms
78,720 KB
testcase_09 AC 58 ms
72,320 KB
testcase_10 AC 50 ms
67,712 KB
testcase_11 AC 52 ms
67,968 KB
testcase_12 AC 88 ms
101,248 KB
testcase_13 AC 83 ms
101,120 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

#初項 a,公差 1,末項 l
l = N
a = 1

wa =  (l - a + 1) * (a + l) // 2

A = list(map(int, input().split()))
idx = A.index(N) + 1

takeda = wa - idx
suzuki = idx

ans = max(takeda - suzuki, 0)
#print(N, ans)

for i in range(N - 1, 0, -1):
    idx = A.index(i) + 1
    takeda -= idx
    suzuki = idx
    #print(i, takeda, suzuki, takeda - suzuki)
    if max(takeda - suzuki, 0) <= ans:
        print(ans)
        exit()
    else:
        ans = takeda - suzuki
print(ans)
0