結果
| 問題 |
No.2740 Old Maid
|
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2025-10-01 00:30:34 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 388 ms / 2,000 ms |
| コード長 | 748 bytes |
| コンパイル時間 | 3,197 ms |
| コンパイル使用メモリ | 290,228 KB |
| 実行使用メモリ | 23,460 KB |
| 最終ジャッジ日時 | 2025-10-01 00:30:50 |
| 合計ジャッジ時間 | 16,463 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 62 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
map<int, int> mp;
rep(i, n) mp[a[i]] = i;
set<int> st;
rep(i, n) st.insert(i);
vector<int> ans;
while (!mp.empty()) {
auto [val, idx] = *mp.begin();
auto nxt = st.upper_bound(idx);
if (nxt == st.end()) {
mp.erase(val);
continue;
}
ans.push_back(val);
ans.push_back(a[*nxt]);
mp.erase(a[*nxt]);
st.erase(*nxt);
mp.erase(val);
st.erase(idx);
}
for (int x : ans) cout << x << ' ';
cout << '\n';
return 0;
}
a01sa01to