結果

問題 No.1687 What the Heck?
ユーザー tassei903tassei903
提出日時 2021-09-24 21:44:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 574 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 108,716 KB
最終ジャッジ日時 2023-09-18 21:03:15
合計ジャッジ時間 3,208 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,264 KB
testcase_01 AC 72 ms
71,240 KB
testcase_02 AC 73 ms
71,236 KB
testcase_03 AC 77 ms
71,284 KB
testcase_04 AC 74 ms
71,380 KB
testcase_05 AC 74 ms
71,352 KB
testcase_06 AC 73 ms
71,484 KB
testcase_07 AC 93 ms
86,100 KB
testcase_08 AC 97 ms
91,008 KB
testcase_09 AC 93 ms
85,824 KB
testcase_10 AC 88 ms
82,276 KB
testcase_11 AC 89 ms
82,272 KB
testcase_12 AC 122 ms
108,652 KB
testcase_13 AC 121 ms
108,684 KB
testcase_14 AC 122 ms
108,636 KB
testcase_15 AC 122 ms
108,716 KB
testcase_16 AC 122 ms
108,540 KB
testcase_17 AC 83 ms
76,352 KB
testcase_18 AC 124 ms
108,548 KB
testcase_19 AC 81 ms
76,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
sys.setrecursionlimit(10**7)
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
n = ni()
p = na()
a = [-1]*n
for i in range(n):
    a[p[i]-1] = i+1
ans = 0
s = n*(n+1)//2
for i in range(n):
    ans = max(ans, s-2*a[-1-i])
    #print(s-2*a[-1-i])
    s-=a[-1-i]
print(ans)
0