# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
499379 | 2021-12-28T08:51:47 Z | colossal_pepe | medians (balkan11_medians) | C++17 | 300 ms | 904 KB |
#include <iostream> #include <vector> #include <cstring> using namespace std; int n, a[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } bool mark[2 * n]; memset(mark, 0, sizeof(mark)); vector<int> ans; for (int i = 0; i < n; i++) { if (not mark[a[i]]) { ans.push_back(a[i]); mark[a[i]] = 1; } int kom = 0, beshi = 0; for (int j = 1; j < 2 * n; j++) { if (mark[j]) { if (j < a[i]) kom++; else if (j > a[i]) beshi++; } } for (int j = i + 1; j < n; j++) { if (kom < i and a[j] < a[i] and not mark[a[j]]) { ans.push_back(a[j]); mark[a[j]] = 1; kom++; } if (beshi < i and a[j] > a[i] and not mark[a[j]]) { ans.push_back(a[j]); mark[a[j]] = 1; beshi++; } } for (int j = 1; j < 2 * n; j++) { if (kom < i and j < a[i] and not mark[j]) { ans.push_back(j); mark[j] = 1; kom++; } if (beshi < i and j > a[i] and not mark[j]) { ans.push_back(j); mark[j] = 1; beshi++; } } } for (int i : ans) { cout << i << ' '; } cout << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Incorrect | 0 ms | 204 KB | Output isn't correct |
4 | Incorrect | 0 ms | 204 KB | Output isn't correct |
5 | Incorrect | 0 ms | 204 KB | Output isn't correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Incorrect | 0 ms | 204 KB | Output isn't correct |
8 | Incorrect | 0 ms | 204 KB | Output isn't correct |
9 | Incorrect | 0 ms | 204 KB | Output isn't correct |
10 | Incorrect | 1 ms | 204 KB | Output isn't correct |
11 | Incorrect | 1 ms | 332 KB | Output isn't correct |
12 | Incorrect | 3 ms | 332 KB | Output isn't correct |
13 | Incorrect | 9 ms | 340 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 32 ms | 352 KB | Output isn't correct |
2 | Incorrect | 135 ms | 392 KB | Output isn't correct |
3 | Execution timed out | 528 ms | 472 KB | Time limit exceeded |
4 | Execution timed out | 1083 ms | 512 KB | Time limit exceeded |
5 | Execution timed out | 1080 ms | 628 KB | Time limit exceeded |
6 | Execution timed out | 1073 ms | 732 KB | Time limit exceeded |
7 | Execution timed out | 1081 ms | 904 KB | Time limit exceeded |