# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4900 | 2014-01-07T06:49:41 Z | gs13068 | medians (balkan11_medians) | C++ | 36 ms | 1408 KB |
#include<cstdio> bool exist[300000]; int main() { int l,r,bef; int i,t,n; scanf("%d",&n); l=1;r=2*n-1; scanf("%d",&t); printf("%d",t); exist[t]=true; bef=t; for(i=1;i<n;i++) { scanf("%d",&t); if(!exist[t]) { exist[t]=true; printf(" %d",t); if(t<bef) { while(exist[l])l++; exist[l]=true; printf(" %d",l); } else { while(exist[r])r--; exist[r]=true; printf(" %d",r); } } else if(t==bef) { while(exist[l])l++; exist[l]=true; printf(" %d",l); while(exist[r])r--; exist[r]=true; printf(" %d",r); } else if(t<bef) { while(exist[l])l++; exist[l]=true; printf(" %d",l); while(exist[l])l++; exist[l]=true; printf(" %d",l); } else { while(exist[r])r--; exist[r]=true; printf(" %d",r); while(exist[r])r--; exist[r]=true; printf(" %d",r); } bef=t; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1408 KB | Output is correct |
2 | Correct | 0 ms | 1408 KB | Output is correct |
3 | Correct | 0 ms | 1408 KB | Output is correct |
4 | Correct | 0 ms | 1408 KB | Output is correct |
5 | Correct | 0 ms | 1408 KB | Output is correct |
6 | Correct | 0 ms | 1408 KB | Output is correct |
7 | Correct | 0 ms | 1408 KB | Output is correct |
8 | Correct | 0 ms | 1408 KB | Output is correct |
9 | Correct | 0 ms | 1408 KB | Output is correct |
10 | Correct | 0 ms | 1408 KB | Output is correct |
11 | Correct | 0 ms | 1408 KB | Output is correct |
12 | Correct | 0 ms | 1408 KB | Output is correct |
13 | Correct | 0 ms | 1408 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1408 KB | Output is correct |
2 | Correct | 0 ms | 1408 KB | Output is correct |
3 | Correct | 0 ms | 1408 KB | Output is correct |
4 | Correct | 3 ms | 1408 KB | Output is correct |
5 | Correct | 6 ms | 1408 KB | Output is correct |
6 | Correct | 23 ms | 1408 KB | Output is correct |
7 | Correct | 36 ms | 1408 KB | Output is correct |