結果

問題 No.1687 What the Heck?
ユーザー TomoyarnTomoyarn
提出日時 2022-01-01 21:35:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 101,248 KB
最終ジャッジ日時 2024-04-18 21:44:43
合計ジャッジ時間 2,591 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,840 KB
testcase_01 AC 41 ms
51,840 KB
testcase_02 AC 42 ms
51,840 KB
testcase_03 AC 43 ms
51,712 KB
testcase_04 AC 40 ms
51,840 KB
testcase_05 AC 36 ms
51,840 KB
testcase_06 AC 38 ms
51,840 KB
testcase_07 AC 52 ms
72,448 KB
testcase_08 AC 59 ms
78,976 KB
testcase_09 AC 56 ms
72,576 KB
testcase_10 AC 51 ms
67,840 KB
testcase_11 AC 51 ms
67,840 KB
testcase_12 AC 88 ms
101,120 KB
testcase_13 AC 90 ms
101,120 KB
testcase_14 AC 88 ms
101,248 KB
testcase_15 AC 83 ms
101,120 KB
testcase_16 AC 81 ms
100,864 KB
testcase_17 AC 48 ms
60,544 KB
testcase_18 AC 89 ms
101,120 KB
testcase_19 AC 42 ms
57,728 KB
権限があれば一括ダウンロードができます

ソースコード

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