結果

問題 No.930 数列圧縮
ユーザー ひばちひばち
提出日時 2019-12-05 21:54:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 946 bytes
コンパイル時間 1,970 ms
コンパイル使用メモリ 170,696 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-24 16:38:19
合計ジャッジ時間 5,753 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 12 ms
4,380 KB
testcase_09 AC 14 ms
4,380 KB
testcase_10 AC 12 ms
4,380 KB
testcase_11 AC 13 ms
4,380 KB
testcase_12 AC 14 ms
4,380 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 7 ms
4,384 KB
testcase_15 AC 17 ms
4,380 KB
testcase_16 AC 17 ms
4,380 KB
testcase_17 AC 17 ms
4,384 KB
testcase_18 AC 17 ms
4,380 KB
testcase_19 AC 17 ms
4,380 KB
testcase_20 AC 17 ms
4,384 KB
testcase_21 AC 17 ms
4,384 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 17 ms
4,380 KB
testcase_24 AC 1 ms
4,388 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for(int i=(int)(n);i>=0;--i)
#define debug(x) cout << #x << "=" << (x) << endl;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
  int N;cin>>N;
  vector<int> A(N);
  rep(i,N)
    cin>>A[i];
  if(A[0]>A[N-1])
    fail("No");
  cout<<"Yes"<<endl;
  stack<int> st;
  st.push(A[0]);
  rep(i,N-2){
    if(st.top()>A[i+1])st.push(A[i+1]);
    else cout<<A[i+1]<<" ";
  }
  while(st.size()){
    cout<<st.top()<<" ";st.pop();
  }
  cout<<endl;
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  solve();
  return 0;
}
0