# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
499379 | colossal_pepe | 중앙값 배열 (balkan11_medians) | C++17 | 1083 ms | 904 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
int n, a[100005];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
bool mark[2 * n];
memset(mark, 0, sizeof(mark));
vector<int> ans;
for (int i = 0; i < n; i++) {
if (not mark[a[i]]) {
ans.push_back(a[i]);
mark[a[i]] = 1;
}
int kom = 0, beshi = 0;
for (int j = 1; j < 2 * n; j++) {
if (mark[j]) {
if (j < a[i]) kom++;
else if (j > a[i]) beshi++;
}
}
for (int j = i + 1; j < n; j++) {
if (kom < i and a[j] < a[i] and not mark[a[j]]) {
ans.push_back(a[j]);
mark[a[j]] = 1;
kom++;
}
if (beshi < i and a[j] > a[i] and not mark[a[j]]) {
ans.push_back(a[j]);
mark[a[j]] = 1;
beshi++;
}
}
for (int j = 1; j < 2 * n; j++) {
if (kom < i and j < a[i] and not mark[j]) {
ans.push_back(j);
mark[j] = 1;
kom++;
}
if (beshi < i and j > a[i] and not mark[j]) {
ans.push_back(j);
mark[j] = 1;
beshi++;
}
}
}
for (int i : ans) {
cout << i << ' ';
}
cout << endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |