Submission #499379

# Submission time Handle Problem Language Result Execution time Memory
499379 2021-12-28T08:51:47 Z colossal_pepe medians (balkan11_medians) C++17
10 / 100
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

In file included from /usr/include/string.h:495,
                 from /usr/include/c++/10/cstring:42,
                 from medians.cpp:3:
In function 'void* memset(void*, int, size_t)',
    inlined from 'int main()' at medians.cpp:16:11:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:71:33: warning: 'void* __builtin_memset(void*, int, long unsigned int)' specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
   71 |   return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 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