Submission #499379

#TimeUsernameProblemLanguageResultExecution timeMemory
499379colossal_pepemedians (balkan11_medians)C++17
10 / 100
1083 ms904 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...