結果

問題 No.1687 What the Heck?
コンテスト
ユーザー mesame3993
提出日時 2021-09-24 22:34:38
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 414 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 253 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 90,496 KB
最終ジャッジ日時 2026-03-26 17:52:39
合計ジャッジ時間 6,503 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 1 WA * 4 TLE * 2 -- * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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