結果
問題 | No.930 数列圧縮 |
ユーザー |
![]() |
提出日時 | 2023-09-28 08:53:14 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 119 ms / 2,000 ms |
コード長 | 387 bytes |
コンパイル時間 | 324 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 102,400 KB |
最終ジャッジ日時 | 2024-07-21 03:24:02 |
合計ジャッジ時間 | 4,574 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
N = int(input())A = list(map(int, input().split()))stack = [A[0]]ans = []for i in range(1, N):while len(stack) >= 2:if stack[-1] < A[i]:ans.append(stack.pop())else:breakif stack[-1] < A[i]:ans.append(A[i])else:stack.append(A[i])if len(ans) == N - 1:print("Yes")print(*ans)else:print("No")