結果
問題 | No.930 数列圧縮 |
ユーザー |
![]() |
提出日時 | 2023-09-28 08:57:49 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 162 ms / 2,000 ms |
コード長 | 387 bytes |
コンパイル時間 | 610 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 20,552 KB |
最終ジャッジ日時 | 2024-07-21 03:28:25 |
合計ジャッジ時間 | 5,090 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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")