結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,224 KB
testcase_01 AC 35 ms
52,224 KB
testcase_02 AC 34 ms
51,968 KB
testcase_03 AC 35 ms
52,224 KB
testcase_04 AC 38 ms
51,712 KB
testcase_05 AC 38 ms
51,968 KB
testcase_06 AC 37 ms
51,712 KB
testcase_07 AC 51 ms
72,704 KB
testcase_08 AC 56 ms
79,104 KB
testcase_09 AC 51 ms
72,704 KB
testcase_10 AC 46 ms
67,968 KB
testcase_11 AC 47 ms
68,096 KB
testcase_12 AC 79 ms
101,504 KB
testcase_13 AC 80 ms
100,992 KB
testcase_14 AC 77 ms
101,376 KB
testcase_15 AC 80 ms
101,248 KB
testcase_16 AC 76 ms
100,992 KB
testcase_17 AC 39 ms
60,800 KB
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 = max(takeda - suzuki, 0)
print(ans)
0