Submission #148403

#TimeUsernameProblemLanguageResultExecution timeMemory
148403본인 하지만 안 어림 ㅋㅋ (#200)List of Unique Integers (FXCUP4_unique)C++17
100 / 100
6 ms512 KiB
#include "unique.h" using namespace std; int leftCount[202]; // [ 0, i ] int rightCount[202]; // [ i, N - 1 ] vector<int> PickUnique(int N) { if(N == 1) return vector<int>(1, 1); vector<int> ans(N, 0); int total = UniqueCount(0, N - 1); leftCount[N - 1] = total; rightCount[0] = total; leftCount[0] = 1; rightCount[N - 1] = 1; for(int i = 1; i < N - 1; i++){ leftCount[i] = UniqueCount(0, i); rightCount[i] = UniqueCount(i, N - 1); } for(int i = 0; i < N; i++){ // 1. i번 뒤에 같은 수가 없어야 함. bool notInRight = i == N - 1 || rightCount[i + 1] < rightCount[i]; bool notInLeft = i == 0 || leftCount[i - 1] < leftCount[i]; ans[i] = notInRight && notInLeft; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...