結果

問題 No.930 数列圧縮
ユーザー chocopuuchocopuu
提出日時 2019-11-22 23:02:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 1,136 bytes
コンパイル時間 1,681 ms
コンパイル使用メモリ 172,836 KB
実行使用メモリ 10,800 KB
最終ジャッジ日時 2024-04-19 12:21:28
合計ジャッジ時間 4,699 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 4 ms
6,944 KB
testcase_08 AC 67 ms
8,840 KB
testcase_09 AC 79 ms
9,212 KB
testcase_10 AC 63 ms
8,116 KB
testcase_11 AC 71 ms
8,540 KB
testcase_12 AC 80 ms
9,264 KB
testcase_13 AC 16 ms
6,940 KB
testcase_14 AC 18 ms
6,944 KB
testcase_15 AC 67 ms
10,028 KB
testcase_16 AC 64 ms
9,472 KB
testcase_17 AC 97 ms
10,800 KB
testcase_18 AC 99 ms
10,232 KB
testcase_19 AC 103 ms
10,368 KB
testcase_20 AC 100 ms
10,344 KB
testcase_21 AC 100 ms
10,216 KB
testcase_22 AC 1 ms
6,940 KB
testcase_23 AC 68 ms
8,832 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;


signed main(){
	int N;
	cin>>N;
	vector<int>a(N);
	int l = -1,r = -1;
	REP(i,N){
		cin>>a[i];
		a[i]--;
	}
	if(a[0]==N-1||a[N-1]==0||a[0]>a[N-1]){
		cout<<"No"<<endl;
		return 0;
	}
	vector<int>ans;
	vector<int>tmp;
	int ma = N - 1;
	set<int>st;
	REP(i,N)st.insert(i);
	FOR(i,1,N){
		if(a[i] == *prev(st.end())){
			while(tmp.size()){
				int t = tmp.back();
				st.erase(t);
				tmp.pop_back();
				ans.push_back(t);
			}
			st.erase(a[i]);
			ans.push_back(a[i]);
		}else{
			tmp.push_back(a[i]);
		}
	}
	cout<<"Yes"<<endl;
	REP(i,ans.size())cout << ans[i] + 1 << " \n"[i+1 == ans.size()];
}
0