結果
問題 | No.930 数列圧縮 |
ユーザー |
![]() |
提出日時 | 2023-09-28 08:58:24 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 110 ms / 2,000 ms |
コード長 | 387 bytes |
コンパイル時間 | 338 ms |
コンパイル使用メモリ | 82,180 KB |
実行使用メモリ | 102,432 KB |
最終ジャッジ日時 | 2024-07-21 03:29:30 |
合計ジャッジ時間 | 4,144 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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: break if 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")