# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
30895 | 2017-07-31T12:53:46 Z | Navick | medians (balkan11_medians) | C++14 | 129 ms | 12956 KB |
#include <bits/stdc++.h> #define F first #define S second #define pii pair<int, int> #define pb push_back using namespace std; typedef long long ll; typedef long double ld; const int N = 2e5 + 10; set<int> st; int a[N], b[N]; int main(){ int n; scanf("%d", &n); for(int i=1; i<2*n; i++) st.insert(i); for(int i=0; i<n; i++){ scanf("%d", a + i); if(i == 0){ printf("%d ", a[i]); st.erase(a[i]); } else{ if(st.find(a[i]) != st.end()){ if(a[i] > a[i - 1]){ printf("%d ", a[i]); st.erase(a[i]); printf("%d ", *(st.rbegin())); st.erase(*st.rbegin()); }else if(a[i] < a[i - 1]){ printf("%d ", a[i]); st.erase(a[i]); printf("%d ", *(st.begin())); st.erase(st.begin()); } } else{ if(a[i] == a[i - 1]){ printf("%d ", *st.begin()); st.erase(st.begin()); printf("%d ", *(st.rbegin())); st.erase(*st.rbegin()); }else if(a[i] < a[i - 1]){ printf("%d ", *st.begin()); st.erase(st.begin()); printf("%d ", *st.begin()); st.erase(st.begin()); }else{ printf("%d ", *st.rbegin()); st.erase(*st.rbegin()); printf("%d ", *st.rbegin()); st.erase(*st.rbegin()); } } } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3584 KB | Output is correct |
2 | Correct | 0 ms | 3584 KB | Output is correct |
3 | Correct | 0 ms | 3584 KB | Output is correct |
4 | Correct | 0 ms | 3584 KB | Output is correct |
5 | Correct | 0 ms | 3584 KB | Output is correct |
6 | Correct | 0 ms | 3584 KB | Output is correct |
7 | Correct | 0 ms | 3584 KB | Output is correct |
8 | Correct | 0 ms | 3584 KB | Output is correct |
9 | Correct | 0 ms | 3584 KB | Output is correct |
10 | Correct | 0 ms | 3584 KB | Output is correct |
11 | Correct | 0 ms | 3584 KB | Output is correct |
12 | Correct | 0 ms | 3716 KB | Output is correct |
13 | Correct | 0 ms | 3716 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3848 KB | Output is correct |
2 | Correct | 0 ms | 3980 KB | Output is correct |
3 | Correct | 9 ms | 4376 KB | Output is correct |
4 | Correct | 6 ms | 5036 KB | Output is correct |
5 | Correct | 33 ms | 6620 KB | Output is correct |
6 | Correct | 99 ms | 9656 KB | Output is correct |
7 | Correct | 129 ms | 12956 KB | Output is correct |