結果

問題 No.930 数列圧縮
ユーザー QCFium
提出日時 2019-11-22 22:25:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 552 bytes
コンパイル時間 1,718 ms
コンパイル使用メモリ 169,680 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-11 04:08:11
合計ジャッジ時間 4,231 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	if (a[0] > a[n - 1]) std::cout << "No" << std::endl;
	else {
		std::cout << "Yes" << std::endl;
		std::vector<int> newed{a[1]};
		for (int i = 2; i + 1 < n; i++) {
			while (newed.size() && a[i] > newed.back()) std::cout << newed.back() << " ", newed.pop_back();
			newed.push_back(a[i]);
		}
		for (auto i : newed) std::cout << i << " ";
		std::cout << a[n - 1] << std::endl;
	}
	return 0;
}
0