Submission #163058

# Submission time Handle Problem Language Result Execution time Memory
163058 2019-11-11T09:39:24 Z Nashik medians (balkan11_medians) C++14
0 / 100
151 ms 22392 KB
#include <iostream>
#include <set>
using namespace std;
set<int> se;
int a[100005];
int b[100005];
int main()
{
    int n,cnt=1;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    for(int i=1;i<=2*n-1;i++){
        se.insert(i);
    }
    a[1]=b[1];
    se.erase(a[1]);
    set<int>::iterator it;
    for(int i=2;i<=n;i++){
        cout<<i<<" "<<cnt<<"\n";
        if(b[i]==b[i-1]){
            ///trebuie bagate doua elemente, unu mai mare ca b[i],unu mai mic ca b[i]
            ///le bagam pe cel mai mare si cel mai mic element nefolosit
            it=se.begin();
            a[++cnt]=*it;
            se.erase(it);
            it=se.end();
            it--;
            a[++cnt]=*it;
            se.erase(it);
        }
        else
        if(b[i]>b[i-1]){
            if(se.count(b[i])==0){
                it=se.begin();
                a[++cnt]=*it;
                se.erase(it);
                it=se.end();
                it--;
                a[++cnt]=*it;
                se.erase(it);
                ///exista deja mijlocul
            }
            else{
                se.erase(b[i]);
                a[++cnt]=b[i];
                it=se.end();
                it--;
                a[++cnt]=*it;
                se.erase(it);
            }
        }
        else{
            if(se.count(b[i])==0){
                it=se.begin();
                a[++cnt]=*it;
                se.erase(it);
                it=se.end();
                it--;
                a[++cnt]=*it;
                se.erase(it);
            }
            else{
                se.erase(b[i]);
                a[++cnt]=b[i];
                it=se.begin();
                a[++cnt]=*it;
                se.erase(it);
            }
        }
    }
    for(int i=1;i<=2*n-1;i++)
        cout<<a[i]<<" ";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Not a permutation
2 Incorrect 2 ms 376 KB Not a permutation
3 Incorrect 2 ms 376 KB Not a permutation
4 Incorrect 2 ms 376 KB Not a permutation
5 Incorrect 2 ms 256 KB Not a permutation
6 Incorrect 2 ms 256 KB Not a permutation
7 Incorrect 2 ms 376 KB Not a permutation
8 Incorrect 2 ms 380 KB Not a permutation
9 Incorrect 2 ms 376 KB Not a permutation
10 Incorrect 2 ms 376 KB Not a permutation
11 Incorrect 2 ms 376 KB Not a permutation
12 Incorrect 3 ms 376 KB Not a permutation
13 Incorrect 3 ms 504 KB Not a permutation
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 632 KB Not a permutation
2 Incorrect 7 ms 888 KB Not a permutation
3 Incorrect 14 ms 1384 KB Not a permutation
4 Incorrect 26 ms 2552 KB Not a permutation
5 Incorrect 55 ms 4856 KB Not a permutation
6 Runtime error 100 ms 14808 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 151 ms 22392 KB Execution killed with signal 11 (could be triggered by violating memory limits)