結果
| 問題 |
No.318 学学学学学
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-10-05 21:25:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 484 ms / 2,000 ms |
| コード長 | 1,067 bytes |
| コンパイル時間 | 1,813 ms |
| コンパイル使用メモリ | 180,984 KB |
| 実行使用メモリ | 36,496 KB |
| 最終ジャッジ日時 | 2025-10-05 21:26:05 |
| 合計ジャッジ時間 | 7,318 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5, inf = 4e18, mod = 998244353;
long long n, a[N], b[N];
map<long long, long long> st, ed;
map<long long, bool> vis, no, one;
priority_queue<long long> q;
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n;
for (long long i = 1; i <= n; ++i) {
cin >> a[i];
if (!st[a[i]]) {
st[a[i]] = i;
}
}
for (long long i = n; i >= 1; --i) {
if (!ed[a[i]]) {
ed[a[i]] = i;
}
}
sort(a + 1, a + n + 1);
for (long long i = 1; i <= n; ++i) {
b[st[a[i]]] = a[i], b[ed[a[i]]] = a[i];
if (st[a[i]] == ed[a[i]]) {
one[a[i]] = 1;
}
}
// for (long long i = 1; i <= n; ++i) {
// cout << b[i] << ' ';
// }
// cout << '\n';
for (long long i = 1; i <= n; ++i) {
if (b[i]) {
if (!vis[b[i]]) {
q.push(b[i]);
}
}
while (!q.empty() && no[q.top()]) {
q.pop();
}
cout << q.top() << ' ';
if (b[i] && vis[b[i]]) {
no[b[i]] = 1;
}
if (b[i] && !vis[b[i]]) {
vis[b[i]] = 1;
}
if (one[b[i]]) {
no[b[i]] = 1;
}
}
return 0;
}
vjudge1