답안 #96934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
96934 2019-02-12T19:16:00 Z dalgerok 중앙값 배열 (balkan11_medians) C++14
10 / 100
12 ms 1280 KB
#include<bits/stdc++.h>
using namespace std;


const int N = 2e5 + 5;



int n, a[N];
int L, R;
map < int, bool > used;


inline void Left(){
    while(used.find(L) != used.end()){
        L += 1;
    }
    cout << L << " ";
    used[L] = true;
    L += 1;
}
inline void Right(){
    while(used.find(R) != used.end()){
        R -= 1;
    }
    cout << R << " ";
    used[R] = true;
    R -= 1;
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    L = 1;
    R = 2 * n - 1;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    cout << a[1] << " ";
    used[a[1]] = true;
    for(int i = 2; i <= n; i++){
        if(used.find(a[i]) != used.end()){
            if(a[i - 1] > a[i]){
                Left();
                Left();
            }
            else if(a[i - 1] < a[i]){
                Right();
                Right();
            }
            else{
                assert(false);
            }
        }
        else{
            used[a[i]] = true;
            cout << a[i] << " ";
            if(a[i - 1] > a[i]){
                Left();
            }
            else if(a[i - 1] < a[i]){
                Right();
            }
            else{
                assert(false);
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Correct 2 ms 384 KB Output is correct
4 Runtime error 2 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Correct 2 ms 384 KB Output is correct
7 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 5 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 5 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 9 ms 1024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 12 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)