結果
問題 |
No.930 数列圧縮
|
ユーザー |
|
提出日時 | 2020-08-04 18:21:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 959 bytes |
コンパイル時間 | 875 ms |
コンパイル使用メモリ | 81,748 KB |
最終ジャッジ日時 | 2025-01-12 14:21:39 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 WA * 1 |
ソースコード
#include <iostream> #include <vector> #include <set> void solve() { int n; std::cin >> n; std::set<int> rem; for (int i = 1; i <= n; ++i) rem.insert(i); std::vector<int> ans, stk; while (n--) { int x; std::cin >> x; rem.erase(x); if (stk.empty() || x < stk.back()) { stk.push_back(x); } else if (rem.lower_bound(stk.front()) == rem.end()) { if (x < stk.front()) { std::cout << "No\n"; return; } while (!stk.empty()) { ans.push_back(stk.back()); stk.pop_back(); } stk.push_back(x); } else { ans.push_back(x); } } std::cout << "Yes\n"; for (auto a : ans) std::cout << a << " "; std::cout << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }