結果

問題 No.930 数列圧縮
ユーザー tassei903tassei903
提出日時 2021-10-10 23:51:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 958 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 86,776 KB
実行使用メモリ 109,372 KB
最終ジャッジ日時 2023-10-12 21:51:21
合計ジャッジ時間 5,705 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,064 KB
testcase_01 AC 74 ms
71,200 KB
testcase_02 AC 73 ms
71,296 KB
testcase_03 AC 72 ms
71,356 KB
testcase_04 AC 76 ms
71,304 KB
testcase_05 AC 90 ms
76,844 KB
testcase_06 WA -
testcase_07 AC 89 ms
76,820 KB
testcase_08 AC 122 ms
97,536 KB
testcase_09 AC 120 ms
95,100 KB
testcase_10 AC 120 ms
97,380 KB
testcase_11 AC 118 ms
94,420 KB
testcase_12 AC 123 ms
96,268 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 130 ms
109,372 KB
testcase_16 AC 133 ms
98,176 KB
testcase_17 AC 133 ms
102,848 KB
testcase_18 AC 128 ms
98,080 KB
testcase_19 AC 129 ms
97,536 KB
testcase_20 AC 130 ms
99,812 KB
testcase_21 AC 126 ms
96,256 KB
testcase_22 AC 74 ms
71,288 KB
testcase_23 AC 127 ms
102,680 KB
testcase_24 AC 72 ms
71,532 KB
testcase_25 AC 74 ms
71,584 KB
testcase_26 AC 76 ms
71,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
sys.setrecursionlimit(10**7)
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################


n = ni()
a = [i-1 for i in na()]
b = n-1
z = []
ans = []

v = [0 for i in range(n)]
def f(b):
    for j in range(b-1,-1,-1):
        if v[j]:continue
        return j
    return -1


for i in range(n):
    #print(i, a[i], b)
    v[a[i]] = 1
    if a[i]==b:
        if len(z)==0:
            No()
            exit()
        #print(i)
        for j in range(len(z)-1):
            ans.append(z.pop()+1)
        ans.append(b+1)
        b = f(b)
        if i!=n-1 and len(z)!=0 and b==z[0]:
            No()
            exit()
    else:
        z.append(a[i])
Yes()
print(*ans)
0