結果

問題 No.1687 What the Heck?
ユーザー mesame3993
提出日時 2021-09-24 22:34:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 414 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 82,308 KB
実行使用メモリ 77,972 KB
最終ジャッジ日時 2024-07-05 10:59:50
合計ジャッジ時間 4,038 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 1 WA * 4 TLE * 2 -- * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
p = list(map(int, input().split()))
p = list(reversed(p))
takeda = [x for x in range(1, n+1)]
ansT, ansS = 0, 0

for i in range(n):
	score = n-i
	tmp = p[i]
	while True:
		tmp += 1
		if tmp in takeda:
			ansT += score
			takeda.remove(tmp)
			break
		if tmp > max(takeda):
			if p[i] in takeda:
				takeda = takeda[1:]
			else:
				ansS += score
				takeda = takeda[1:]
			break
print(ansT - ansS)
0