結果
問題 | No.930 数列圧縮 |
ユーザー |
![]() |
提出日時 | 2023-09-28 08:51:54 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 390 bytes |
コンパイル時間 | 380 ms |
コンパイル使用メモリ | 82,200 KB |
実行使用メモリ | 102,772 KB |
最終ジャッジ日時 | 2024-07-21 03:21:58 |
合計ジャッジ時間 | 6,762 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 3 WA * 21 |
ソースコード
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(len(ans)) print(*ans) else: print("No")