結果
問題 | No.1687 What the Heck? |
ユーザー |
|
提出日時 | 2021-10-06 02:25:08 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 87 ms / 2,000 ms |
コード長 | 211 bytes |
コンパイル時間 | 173 ms |
コンパイル使用メモリ | 82,352 KB |
実行使用メモリ | 106,092 KB |
最終ジャッジ日時 | 2024-07-23 02:40:48 |
合計ジャッジ時間 | 2,248 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
N=int(input()) P=list(map(lambda x:x-1,map(int, input().split()))) Q=[0]*N for i,p in enumerate(P): Q[p]=i res=0 S=N*(N+1)//2 for n in range(N)[::-1]: res=max(S - 2*(Q[n]+1),res) S-=Q[n]+1 print(res)