Submission #852453

# Submission time Handle Problem Language Result Execution time Memory
852453 2023-09-21T20:09:50 Z sofijavelkovska medians (balkan11_medians) C++17
5 / 100
88 ms 12052 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, x, y, i;
    set<int> notused;
    cin >> n;
    int a[2*n-1], b[n];
    for (i=0; i<n; i++)
        cin >> b[i];
    for (i=1; i<=2*n-1; i++)
        notused.insert(i);
    a[0]=b[0];
    for (i=1; i<n; i++)
    {
        auto it=notused.lower_bound(b[i]);
        if (b[i]==b[i-1])
        {
            x=*it;
            it--;
            y=*it;
        }
        if (b[i]>b[i-1])
        {
            x=*it;
            it++;
            y=*it;
        }
        if (b[i]<b[i-1])
        {
            if (*it!=b[i])
                it--;
            x=*it;
            it--;
            y=*it;
        }
        a[2*i-1]=x;
        notused.erase(x);
        a[2*i]=y;
        notused.erase(y);
    }
    for (i=0; i<2*n-1; i++)
        cout << a[i] << " ";

    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 1 ms 348 KB Not a permutation
4 Incorrect 0 ms 348 KB Not a permutation
5 Incorrect 0 ms 348 KB Not a permutation
6 Correct 0 ms 348 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 348 KB Not a permutation
10 Incorrect 0 ms 348 KB Not a permutation
11 Incorrect 1 ms 344 KB Not a permutation
12 Incorrect 1 ms 348 KB Not a permutation
13 Incorrect 1 ms 348 KB Not a permutation
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 604 KB Not a permutation
2 Incorrect 3 ms 860 KB Not a permutation
3 Incorrect 8 ms 1116 KB Not a permutation
4 Incorrect 12 ms 2140 KB Not a permutation
5 Incorrect 26 ms 4064 KB Not a permutation
6 Incorrect 51 ms 7760 KB Not a permutation
7 Incorrect 88 ms 12052 KB Not a permutation