結果
問題 |
No.930 数列圧縮
|
ユーザー |
![]() |
提出日時 | 2019-11-22 22:55:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 905 bytes |
コンパイル時間 | 1,665 ms |
コンパイル使用メモリ | 173,304 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-11 04:33:02 |
合計ジャッジ時間 | 5,643 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 16 |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); int n; cin>>n; int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } vector<int> ans; int now = a[0]; stack<int> st; st.push(a[0]); for(int i=1;i<n;i++){ if(now < a[i]){ while(now != a[0] && now < a[i]){ ans.push_back(now); now = st.top(); st.pop(); if(now == a[0]) st.push(a[0]); } ans.push_back(a[i]); } else{ st.push(now); now = a[i]; } } if(ans.size()==n-1){ cout << "Yes\n"; for(auto i:ans){ cout << i << " "; } cout << "\n"; return 0; } cout << "No\n"; }