답안 #147626

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147626 2019-08-30T10:25:22 Z zubec 중앙값 배열 (balkan11_medians) C++14
5 / 100
118 ms 9976 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int n, b[100100];

set<int> q;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin >> n;
    for (int i = 1; i <= 2*n-1; i++)
        q.insert(i);
    vector <int> ans;
    for (int i = 1; i <= n; i++){
        cin >> b[i];
        if (i == 1){
            q.erase(b[i]);
            ans.push_back(b[i]);
            continue;
        }
        if (b[i] == b[i-1]){
            if (q.find(b[i]) != q.end()){
                ans.push_back(b[i]);
                q.erase(b[i]);
                ans.push_back(*q.begin());
                q.erase(q.begin());
            } else {
                ans.push_back(*q.begin());
                q.erase(q.begin());
                ans.push_back(*prev(q.end()));
                q.erase(prev(q.end()));
            }
        }
        else if (b[i] > b[i-1]){
            if (q.find(b[i]) != q.end()){
                ans.push_back(b[i]);
                q.erase(b[i]);
                ans.push_back(*q.begin());
                q.erase(q.begin());
            } else {
                ans.push_back(*q.begin());
                q.erase(q.begin());
                ans.push_back(*q.begin());
                q.erase(q.begin());
            }
        }
        else {
            if (q.find(b[i]) != q.end()){
                ans.push_back(b[i]);
                q.erase(b[i]);
                ans.push_back(*prev(q.end()));
                q.erase(prev(q.end()));
            } else {
                ans.push_back(*prev(q.end()));
                q.erase(prev(q.end()));
                ans.push_back(*prev(q.end()));
                q.erase(prev(q.end()));
            }
        }

    }
    for (int i : ans)
        cout << i << ' ';
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Incorrect 2 ms 504 KB Output isn't correct
6 Correct 2 ms 376 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Incorrect 2 ms 424 KB Output isn't correct
9 Incorrect 2 ms 376 KB Output isn't correct
10 Incorrect 2 ms 376 KB Output isn't correct
11 Incorrect 3 ms 376 KB Output isn't correct
12 Incorrect 2 ms 376 KB Output isn't correct
13 Incorrect 3 ms 504 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
2 Incorrect 5 ms 760 KB Output isn't correct
3 Incorrect 9 ms 1272 KB Output isn't correct
4 Incorrect 17 ms 2048 KB Output isn't correct
5 Incorrect 33 ms 3576 KB Output isn't correct
6 Incorrect 71 ms 6656 KB Output isn't correct
7 Incorrect 118 ms 9976 KB Output isn't correct