結果
問題 |
No.1687 What the Heck?
|
ユーザー |
|
提出日時 | 2021-09-24 21:34:56 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 519 bytes |
コンパイル時間 | 137 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 104,704 KB |
最終ジャッジ日時 | 2024-07-05 10:10:12 |
合計ジャッジ時間 | 2,239 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 WA * 4 |
ソースコード
import sys input = sys.stdin.readline from collections import * N = int(input()) P = list(map(int, input().split())) flag = [False]*N ans = 0 for i in range(N-1, -1, -1): P[i] -= 1 if P[i]==N-1: if flag[N-1]: ans -= i+1 else: flag[N-1] = True else: if flag[P[i]+1]: if flag[P[i]]: ans -= i+1 else: flag[P[i]] = True else: flag[P[i]+1] = True ans += i+1 print(ans)