# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
50215 | 2018-06-08T10:28:11 Z | rondojim | medians (balkan11_medians) | C++17 | 300 ms | 22540 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; int A[2 * MAXN], B[MAXN], N, cnt[2 * MAXN]; set<int> S; int main(){ scanf("%d", &N); for(int i=1; i<=N; ++i){ scanf("%d", &B[i]); cnt[B[i]]++; } for(int i=1; i<2*N; ++i) S.insert(i); for(int i=1; i<N; ++i){ if(S.find(B[i]) != S.end()) S.erase(S.find(B[i])); } A[1] = B[1]; for(int i=N; i>=2; --i){ int p = B[i - 1], c = B[i]; set<int>::iterator it; if(c > p){ for(int j=2*i-1; j>=2*i-2; --j){ auto it = S.lower_bound(B[i]); A[j] = *it; S.erase(it); } } else if(c < p){ for(int j=2*i-1; j>=2*i-2; --j){ it = S.lower_bound(B[i - 1]); if(*it >= B[i - 1]) --it; A[j] = *it; S.erase(it); } } else{ it = S.upper_bound(B[i]); A[2 * i - 1] = *it; S.erase(it); it = S.lower_bound(B[i]); if(it == S.end()) --it; else if(*it >= B[i]) --it; A[2 * i - 2] = *it; S.erase(it); } if(cnt[B[i - 1]] == 1) S.insert(B[i - 1]); else cnt[B[i - 1]]--; } for(int i=1; i<2*N; ++i) printf("%d ", A[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Runtime error | 5 ms | 760 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Correct | 2 ms | 760 KB | Output is correct |
4 | Runtime error | 3 ms | 872 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
5 | Runtime error | 6 ms | 916 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
6 | Runtime error | 7 ms | 1080 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Runtime error | 2 ms | 1080 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
8 | Runtime error | 5 ms | 1080 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
9 | Execution timed out | 1077 ms | 1080 KB | Time limit exceeded |
10 | Runtime error | 4 ms | 1080 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
11 | Runtime error | 2 ms | 1080 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
12 | Correct | 2 ms | 1080 KB | Output is correct |
13 | Execution timed out | 1085 ms | 1080 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 1504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Correct | 6 ms | 1636 KB | Output is correct |
3 | Runtime error | 11 ms | 2892 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
4 | Execution timed out | 1071 ms | 3584 KB | Time limit exceeded |
5 | Runtime error | 40 ms | 8016 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
6 | Runtime error | 77 ms | 15052 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Runtime error | 128 ms | 22540 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |