# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
154353 | dolphingarlic | 중앙값 배열 (balkan11_medians) | C++14 | 127 ms | 11528 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
int b[100001];
set<int> s;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, curr;
cin >> n;
FOR(i, 1, n + 1) {
cin >> b[i];
s.insert(2 * i - 1);
s.insert(2 * i);
}
s.erase(2 * n);
cout << b[1] << ' ';
s.erase(b[1]);
FOR(i, 2, n + 1) {
if (b[i] == b[i - 1]) {
cout << *s.begin() << ' ';
s.erase(*s.begin());
cout << *s.rbegin() << ' ';
s.erase(*s.rbegin());
} else if (b[i] > b[i - 1]) {
if (s.find(b[i]) == s.end()) {
cout << *s.rbegin() << ' ';
s.erase(*s.rbegin());
cout << *s.rbegin() << ' ';
s.erase(*s.rbegin());
} else {
cout << b[i] << ' ';
s.erase(b[i]);
cout << *s.rbegin() << ' ';
s.erase(*s.rbegin());
}
} else {
if (s.find(b[i]) == s.end()) {
cout << *s.begin() << ' ';
s.erase(*s.begin());
cout << *s.begin() << ' ';
s.erase(*s.begin());
} else {
cout << b[i] << ' ';
s.erase(b[i]);
cout << *s.begin() << ' ';
s.erase(*s.begin());
}
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |