Submission #151004

#TimeUsernameProblemLanguageResultExecution timeMemory
151004JustInCaseList of Unique Integers (FXCUP4_unique)C++17
100 / 100
2 ms508 KiB
#include <bits/stdc++.h> #ifdef LOCAL #include "grader.cpp" #else #include "unique.h" #endif #define pick_unique PickUnique #define unique_count UniqueCount #define int32_t int #define int64_t long long std::vector< int32_t > pick_unique(int32_t n) { std::vector< int32_t > cntFront(n), cntBack(n), res(n, 0); for(int32_t i = 0; i < n; i++) { cntFront[i] = unique_count(0, i); cntBack[i] = unique_count(i, n - 1); } for(int32_t i = 0; i < n; i++) { if(i == 0) { if(cntBack[i] > cntBack[i + 1]) { res[i] = 1; } } else if(i == n - 1) { if(cntFront[i] > cntFront[i - 1]) { res[i] = 1; } } else { if(cntFront[i] > cntFront[i - 1] && cntBack[i] > cntBack[i + 1]) { res[i] = 1; } } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...