# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4737 | ainta | medians (balkan11_medians) | C++98 | 99 ms | 10548 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma warning(disable:4996)
#include<stdio.h>
#include<algorithm>
#include<set>
using namespace std;
set<int>Set;
set<int>::iterator it, it2;
int main()
{
int a, b, i, n;
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |