結果

問題 No.930 数列圧縮
ユーザー le_panda_noirle_panda_noir
提出日時 2020-04-10 23:08:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,323 bytes
コンパイル時間 1,096 ms
コンパイル使用メモリ 104,340 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-14 04:28:22
合計ジャッジ時間 6,452 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template<class T>using vv = vector<vector<T>>;

#define in(v) v; cin >> v;
// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}


#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif

int main() {
  int in(N);

  int in(left);
  deque<int> q;
  rep(i, N-2) {
    int in(a);
    q.push_back(a);
  }
  int in(right);

  if (left > right){
    cout << "No\n";
    return 0;
  }
  vi ans;
  while (!q.empty()) {
    if (left < q.front()) {
      ans.push_back(q.front()); q.pop_front();
    } else if (q.back() < right) {
      ans.push_back(q.back()); q.pop_back();
    } else {
      while (q.size() > 1 && q[0] < q[1]) {
        ans.push_back(q.front());
        q.pop_front();
      }
      if (left < q.front() || q.back() < right)
        continue;
      cout << "No\n";
      return 0;
    }
  }
  ans.push_back(left);
  cout << "Yes\n";
  rep(i, ans.size()) {
    if (i)
      cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}
0