結果
問題 | No.930 数列圧縮 |
ユーザー |
![]() |
提出日時 | 2019-12-01 19:52:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 41 ms / 2,000 ms |
コード長 | 682 bytes |
コンパイル時間 | 537 ms |
コンパイル使用メモリ | 74,144 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-21 16:08:05 |
合計ジャッジ時間 | 2,756 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include<iostream>#include<vector>#include<algorithm>#include<set>#include<map>#include<cmath>using namespace std;typedef long long ll;const int inf = 1e8;int main(){int N; cin >> N;vector<int> a(N);for(int i = 0 ;i < N; i++){ cin >> a[i];}if( a[0] > a[N-1]){ cout << "No" << endl; return 0;}cout << "Yes" << endl;vector<int> ans;for(int i = 0; i < N-1; i++){if( a[0] < a[i]){ ans.push_back(a[i]);}}for(int i = N-1; i >= 0; i--){ //残っているのは右端を残し、全てa[0]未満の要素if(a[i] <= a[0]){ ans.push_back(a[i]);}}for(auto ne : ans){ cout << ne << " ";}cout << endl;return 0;}