Submission #96934

# Submission time Handle Problem Language Result Execution time Memory
96934 2019-02-12T19:16:00 Z dalgerok medians (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);
            }
        }
    }
}
# Verdict Execution time Memory 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)
# Verdict Execution time Memory 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)