Submission #83534

# Submission time Handle Problem Language Result Execution time Memory
83534 2018-11-08T19:19:01 Z Linst90 medians (balkan11_medians) C++11
100 / 100
138 ms 13132 KB
#include<iostream>
#include<map>
using namespace::std;

int r,l;
map<int,bool> m;

void gf(){
    while(m.count(l)) ++l;
    cout<<l<<' ';
    m[l++]=1;
}

void gl(){
    while(m.count(r)) --r;
    cout<<r<<' ';
    m[r--]=1;
}

int main(){
    int n;
    cin>>n;
    r=2*n-1;
    l=1;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    cout<<a[0]<<' ';
    m[a[0]]=1;
    for(int i=1;i<n;i++){
        if(m.count(a[i])){
            if(a[i-1]>a[i]) gf(),gf();
            else if(a[i-1]<a[i]) gl(),gl();
            else gf(),gl();
        }else{
            m[a[i]]=1;
            cout<<a[i]<<' ';
            if(a[i-1]>a[i]) gf();
            else gl();
        }
    }
    cout<<'\n';
}
//129856734
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 476 KB Output is correct
3 Correct 2 ms 476 KB Output is correct
4 Correct 2 ms 624 KB Output is correct
5 Correct 2 ms 624 KB Output is correct
6 Correct 2 ms 624 KB Output is correct
7 Correct 2 ms 624 KB Output is correct
8 Correct 2 ms 692 KB Output is correct
9 Correct 2 ms 700 KB Output is correct
10 Correct 3 ms 700 KB Output is correct
11 Correct 2 ms 700 KB Output is correct
12 Correct 2 ms 756 KB Output is correct
13 Correct 3 ms 756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 816 KB Output is correct
2 Correct 6 ms 1084 KB Output is correct
3 Correct 11 ms 1700 KB Output is correct
4 Correct 21 ms 2600 KB Output is correct
5 Correct 42 ms 4580 KB Output is correct
6 Correct 83 ms 8392 KB Output is correct
7 Correct 138 ms 13132 KB Output is correct