#include "unique.h"
#include <iostream>
std::vector<int> PickUnique(int N)
{
std::vector<int> arr1, arr2, arr3, answer;
int front = 0, end = N - 1;
int count = UniqueCount(0, N-1);
while (++front < N) {
int ucount = UniqueCount(front, N-1);
if (ucount >= count) {
arr1.push_back(0);
}
else {
arr1.push_back(1);
}
count = ucount;
}
arr1.push_back(1);
count = UniqueCount(0, N-1);
while (--end >= 0) {
int ucount = UniqueCount(0, end);
if (ucount >= count) {
arr2.push_back(0);
}
else {
arr2.push_back(1);
}
count = ucount;
}
arr2.push_back(1);
while (!arr1.empty()) {
arr3.push_back(arr1.back());
arr1.pop_back();
}
while (!arr2.empty() && !arr3.empty()) {
answer.push_back(arr2.back() && arr3.back());
arr2.pop_back();
arr3.pop_back();
}
return answer;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Correct : C = 4 |
2 |
Correct |
5 ms |
384 KB |
Correct : C = 10 |
3 |
Correct |
6 ms |
256 KB |
Correct : C = 50 |
4 |
Correct |
5 ms |
384 KB |
Correct : C = 100 |
5 |
Correct |
5 ms |
332 KB |
Correct : C = 100 |
6 |
Correct |
5 ms |
384 KB |
Correct : C = 154 |
7 |
Correct |
6 ms |
384 KB |
Correct : C = 200 |
8 |
Correct |
6 ms |
512 KB |
Correct : C = 300 |
9 |
Correct |
6 ms |
512 KB |
Correct : C = 356 |
10 |
Correct |
5 ms |
512 KB |
Correct : C = 400 |
11 |
Correct |
6 ms |
512 KB |
Correct : C = 400 |
12 |
Correct |
5 ms |
512 KB |
Correct : C = 400 |
13 |
Correct |
6 ms |
512 KB |
Correct : C = 400 |
14 |
Correct |
6 ms |
384 KB |
Correct : C = 400 |
15 |
Correct |
6 ms |
512 KB |
Correct : C = 400 |