結果

問題 No.930 数列圧縮
ユーザー chocopuuchocopuu
提出日時 2019-11-22 22:57:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,079 bytes
コンパイル時間 1,648 ms
コンパイル使用メモリ 167,940 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 12:18:00
合計ジャッジ時間 5,008 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
6,944 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 15 ms
6,940 KB
testcase_14 AC 18 ms
6,944 KB
testcase_15 AC 36 ms
6,944 KB
testcase_16 AC 35 ms
6,940 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 34 ms
6,944 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 1 ms
6,944 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;
	FOR(i,1,N){
		if(a[i] == ma){
			ma--;
			while(tmp.size()){
				int t = tmp.back();
				if(t==ma)ma--;
				tmp.pop_back();
				ans.push_back(t);
			}
			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