結果

問題 No.930 数列圧縮
ユーザー
提出日時 2020-11-28 10:36:22
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,130 bytes
コンパイル時間 1,018 ms
コンパイル使用メモリ 97,784 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-12 22:14:21
合計ジャッジ時間 5,463 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 3 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
int n;
cin >> n;
priority_queue<int,vector<int>,greater<int>> que;
vector<int> ans;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
bool b = false;
int co;
if (que.empty()) {
que.push(a);
}
else {
while (1) {
if (que.empty() || a < que.top()) {
if (b) {
que.push(co);
ans.emplace_back(a);
}
else {
que.push(a);
}
break;
}
else if (!b && a > que.top()) {
co = que.top();
que.pop();
b = true;
continue;
}
else if (a > que.top()) {
ans.emplace_back(que.top());
que.pop();
continue;
}
}
}
}
if (ans.size() == n - 1) {
cout << "Yes" << endl;
for (int i = 0; i < n - 1; i++) {
cout << ans[i];
if (i != n - 2) {
cout << " ";
}
}
cout << endl;
}
else {
cout << "No" << endl;
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0