結果
問題 |
No.930 数列圧縮
|
ユーザー |
![]() |
提出日時 | 2019-11-22 22:57:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 934 bytes |
コンパイル時間 | 1,742 ms |
コンパイル使用メモリ | 173,104 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-11 04:34:26 |
合計ジャッジ時間 | 5,848 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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]){ ans.push_back(now); if(st.top() > a[i]) break; 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"; }