結果

問題 No.1687 What the Heck?
ユーザー roarisroaris
提出日時 2021-09-24 23:45:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 650 ms / 2,000 ms
コード長 282 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 112,620 KB
最終ジャッジ日時 2023-09-18 22:28:25
合計ジャッジ時間 7,796 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,512 KB
testcase_01 AC 96 ms
71,680 KB
testcase_02 AC 98 ms
71,796 KB
testcase_03 AC 98 ms
71,356 KB
testcase_04 AC 97 ms
71,524 KB
testcase_05 AC 93 ms
71,360 KB
testcase_06 AC 96 ms
71,752 KB
testcase_07 AC 268 ms
87,648 KB
testcase_08 AC 337 ms
93,588 KB
testcase_09 AC 270 ms
87,680 KB
testcase_10 AC 202 ms
85,352 KB
testcase_11 AC 211 ms
85,612 KB
testcase_12 AC 646 ms
112,480 KB
testcase_13 AC 641 ms
112,620 KB
testcase_14 AC 650 ms
112,368 KB
testcase_15 AC 633 ms
112,360 KB
testcase_16 AC 627 ms
112,528 KB
testcase_17 AC 131 ms
78,576 KB
testcase_18 AC 636 ms
112,468 KB
testcase_19 AC 105 ms
77,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

N = int(input())
P = list(map(int, input().split()))
Pi = [(P[i], i+1) for i in range(N)]
Pi.sort(reverse=True)
ans = 0
now = N*(N+1)//2

for _, i in Pi:
    now -= 2*i
    ans = max(ans, now)
    now += i

print(ans)
0