結果

問題 No.930 数列圧縮
ユーザー mmn15277198mmn15277198
提出日時 2020-11-28 11:30:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 987 bytes
コンパイル時間 899 ms
コンパイル使用メモリ 100,400 KB
実行使用メモリ 8,664 KB
最終ジャッジ日時 2023-10-09 23:47:40
合計ジャッジ時間 3,682 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 37 ms
7,052 KB
testcase_09 AC 43 ms
7,540 KB
testcase_10 AC 34 ms
6,772 KB
testcase_11 AC 37 ms
7,120 KB
testcase_12 AC 42 ms
7,648 KB
testcase_13 AC 23 ms
5,820 KB
testcase_14 AC 28 ms
6,400 KB
testcase_15 AC 53 ms
8,504 KB
testcase_16 AC 52 ms
8,532 KB
testcase_17 AC 54 ms
8,400 KB
testcase_18 AC 53 ms
8,484 KB
testcase_19 AC 53 ms
8,464 KB
testcase_20 AC 54 ms
8,460 KB
testcase_21 AC 53 ms
8,664 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 53 ms
8,500 KB
testcase_24 AC 2 ms
4,352 KB
testcase_25 AC 1 ms
4,352 KB
testcase_26 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll inf = 1e9 + 7;

int main(){	
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecison(15);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	map<int , int> b;
	int now = a[0];
	vector<int> ans;
	for(int i = 1; i < n - 1; i++){
		if(now < a[i]){
			b[i] = 1;
			ans.push_back(a[i]);
		}else{
			now = a[i];
		}
	}
	now = a[n - 1];
	for(int i = n - 2; i >= 0; i--){
		if(b[i] == 1)continue;
		if(now > a[i]){
			b[i] = 1;
			ans.push_back(a[i]);
		}else{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	for(int i = 0; i < ans.size(); i++){
		cout << ans[i];
		if(i != ans.size() - 1){
			cout << " ";
		}else{
			cout << endl;
		}
	}
	return 0;
}
 
 
0