Submission #1029039

# Submission time Handle Problem Language Result Execution time Memory
1029039 2024-07-20T11:35:18 Z lucri medians (balkan11_medians) C++17
5 / 100
160 ms 2132 KB
#include <iostream>
using namespace std;
int n,ant,act;
bool aint[800010];
void blocheaza(int poz,int b,int e,int pozu)
{
    if(pozu<b||pozu>e)
        return;
    if(b==e)
    {
        aint[poz]=true;
        return;
    }
    blocheaza(poz*2,b,(b+e)/2,pozu);
    blocheaza(poz*2+1,(b+e)/2+1,e,pozu);
    aint[poz]=(aint[poz*2]&aint[poz*2+1]);
}
int maxim(int poz,int b,int e)
{
    if(b==e)
        return b;
    if(aint[poz*2+1]==false)
        return maxim(poz*2+1,(b+e)/2+1,e);
    return maxim(poz*2,b,(b+e)/2);
}
int minim(int poz,int b,int e)
{
    if(b==e)
        return b;
    if(aint[poz*2]==false)
        return minim(poz*2,b,(b+e)/2);
    return minim(poz*2+1,(b+e)/2+1,e);
}
int main()
{
    cin>>n>>ant;
    cout<<ant<<' ';
    blocheaza(1,1,2*n-1,ant);
    for(int i=2;i<=n;++i)
    {
        cin>>act;
        if(act>ant)
        {
            cout<<act<<' ';
            blocheaza(1,1,2*n-1,act);
            ant=maxim(1,1,2*n-1);
            cout<<ant<<' ';
            blocheaza(1,1,2*n-1,ant);
        }
        else if(act<ant)
        {
            cout<<act<<' ';
            blocheaza(1,1,2*n-1,act);
            ant=minim(1,1,2*n-1);
            cout<<ant<<' ';
            blocheaza(1,1,2*n-1,ant);
        }
        else
        {
            ant=minim(1,1,2*n-1);
            cout<<ant<<' ';
            blocheaza(1,1,2*n-1,ant);
            ant=maxim(1,1,2*n-1);
            cout<<ant<<' ';
            blocheaza(1,1,2*n-1,ant);
        }
        ant=act;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Not a permutation
2 Incorrect 0 ms 348 KB Not a permutation
3 Incorrect 0 ms 348 KB Not a permutation
4 Incorrect 0 ms 448 KB Not a permutation
5 Incorrect 0 ms 348 KB Not a permutation
6 Correct 1 ms 344 KB Output is correct
7 Incorrect 1 ms 348 KB Not a permutation
8 Incorrect 0 ms 348 KB Not a permutation
9 Incorrect 0 ms 600 KB Not a permutation
10 Incorrect 1 ms 348 KB Not a permutation
11 Incorrect 1 ms 348 KB Not a permutation
12 Incorrect 1 ms 348 KB Not a permutation
13 Incorrect 2 ms 348 KB Not a permutation
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 348 KB Not a permutation
2 Incorrect 8 ms 348 KB Not a permutation
3 Incorrect 15 ms 564 KB Not a permutation
4 Incorrect 26 ms 732 KB Not a permutation
5 Incorrect 51 ms 696 KB Not a permutation
6 Incorrect 102 ms 1252 KB Not a permutation
7 Incorrect 160 ms 2132 KB Not a permutation