Submission #4735

# Submission time Handle Problem Language Result Execution time Memory
4735 2013-12-23T11:12:58 Z ainta medians (balkan11_medians) C++
100 / 100
109 ms 12108 KB
#pragma warning(disable:4996)
#include<stdio.h>
#include<algorithm>
#include<set>
using namespace std;
int n, w[200010];
int p[200010];
set<int>Set;
set<int>::iterator it, it2;
int main()
{
    int a, b, i;
    scanf("%d", &n);
    for (i = 1; i <= 2*n-1; i++)
        Set.insert(i);
    for (i = 1; i <= n; i++){
        scanf("%d", &a);
        if (i == 1){
            printf("%d ", a);
            Set.erase(Set.find(a));
            b = a;
            continue;
        }
        if (Set.find(a) != Set.end()){
            Set.erase(Set.find(a));
            printf("%d ", a);
            if (a < b)it = Set.begin();
            else it = Set.end(), it--;
            printf("%d ", *it);
            Set.erase(it);
            b = a;
            continue;
        }
        if (a <= b)it = Set.begin();
        else it = Set.end(), it--;
        printf("%d ", *it);
        Set.erase(it);
        if (a < b)it = Set.begin();
        else it = Set.end(), it--;
        printf("%d ", *it);
        Set.erase(it);
        b = a;
    }
    return 0;
}

Compilation message

medians.cpp:1:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)
 ^
medians.cpp: In function 'int main()':
medians.cpp:13:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
medians.cpp:17:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a);
                        ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2736 KB Output is correct
2 Correct 0 ms 2736 KB Output is correct
3 Correct 0 ms 2736 KB Output is correct
4 Correct 0 ms 2736 KB Output is correct
5 Correct 0 ms 2736 KB Output is correct
6 Correct 0 ms 2736 KB Output is correct
7 Correct 0 ms 2736 KB Output is correct
8 Correct 0 ms 2736 KB Output is correct
9 Correct 0 ms 2736 KB Output is correct
10 Correct 0 ms 2736 KB Output is correct
11 Correct 0 ms 2736 KB Output is correct
12 Correct 0 ms 2868 KB Output is correct
13 Correct 0 ms 2868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3000 KB Output is correct
2 Correct 3 ms 3132 KB Output is correct
3 Correct 6 ms 3528 KB Output is correct
4 Correct 9 ms 4188 KB Output is correct
5 Correct 29 ms 5772 KB Output is correct
6 Correct 59 ms 8808 KB Output is correct
7 Correct 109 ms 12108 KB Output is correct