結果
問題 |
No.1687 What the Heck?
|
ユーザー |
![]() |
提出日時 | 2025-06-12 21:34:28 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 542 bytes |
コンパイル時間 | 311 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 109,440 KB |
最終ジャッジ日時 | 2025-06-12 21:35:13 |
合計ジャッジ時間 | 2,848 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 1 WA * 17 |
ソースコード
import sys from collections import deque def main(): N = int(sys.stdin.readline()) P = list(map(int, sys.stdin.readline().split())) i_list = list(range(1, N+1))[::-1] # 轮次按从大到小排序 Q = deque(range(1, N+1)) total = 0 for i in i_list: p = P[i-1] if Q[-1] > p: total += i Q.pop() elif Q[0] < p: total -= i Q.popleft() else: Q.popleft() print(total) if __name__ == "__main__": main()