結果

問題 No.1687 What the Heck?
ユーザー TomoyarnTomoyarn
提出日時 2022-01-01 21:34:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 491 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 108,160 KB
最終ジャッジ日時 2024-04-18 21:43:50
合計ジャッジ時間 5,887 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
57,728 KB
testcase_01 AC 35 ms
51,840 KB
testcase_02 AC 36 ms
52,224 KB
testcase_03 AC 35 ms
52,224 KB
testcase_04 AC 36 ms
51,840 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 51 ms
72,832 KB
testcase_08 AC 56 ms
78,848 KB
testcase_09 AC 52 ms
72,576 KB
testcase_10 AC 1,135 ms
69,248 KB
testcase_11 AC 48 ms
68,164 KB
testcase_12 AC 80 ms
101,248 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

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:
        ans = max(takeda - suzuki, 0)
    if ans < takeda:
        break
print(ans)
0