답안 #148403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148403 2019-09-01T04:18:22 Z 본인 하지만 안 어림 ㅋㅋ(#3569, gs13105, xdoju, gs13068) List of Unique Integers (FXCUP4_unique) C++17
100 / 100
6 ms 512 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Correct : C = 1
2 Correct 5 ms 256 KB Correct : C = 7
3 Correct 5 ms 384 KB Correct : C = 47
4 Correct 6 ms 384 KB Correct : C = 97
5 Correct 5 ms 384 KB Correct : C = 97
6 Correct 5 ms 256 KB Correct : C = 151
7 Correct 6 ms 384 KB Correct : C = 197
8 Correct 5 ms 384 KB Correct : C = 297
9 Correct 5 ms 512 KB Correct : C = 353
10 Correct 6 ms 512 KB Correct : C = 397
11 Correct 5 ms 512 KB Correct : C = 397
12 Correct 6 ms 512 KB Correct : C = 397
13 Correct 5 ms 512 KB Correct : C = 397
14 Correct 5 ms 512 KB Correct : C = 397
15 Correct 6 ms 512 KB Correct : C = 397