답안 #149140

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149140 2019-09-01T05:48:35 Z Cafe Maru(#3599, bryan, pps789, kazel) 포도주 시음 (FXCUP4_wine) C++17
0 / 100
9 ms 780 KB
#include "bartender.h"

std::vector<int> BlendWines(int K, std::vector<int> R){
  int N = R.size();
  std::vector<int> r(N);
  for (int ni = 0; ni < N; ni++) {
    if (R[ni] == 30) r[ni] = 11;
    else r[ni] = R[ni] % 10 + 1;
  }
  return r;
}
#include "taster.h"

int Compare2(int N, int a, int b) {
  if (a < N && b < N) return Compare(a, b);
  if (b < N) return 1;
  return -1;
}

std::vector<int> SortWines(int K, std::vector<int> A) {
  int N = A.size();
  std::vector<int> r(30);
  std::vector<int> cc[12];
  for (int ni = 0; ni < 30; ni++) {
    int aa;
    if (ni < N) aa = A[ni];
    else if (ni == 29) aa = 11;
    else if (ni % 10 == 9) aa = 1;
    else aa = ni % 10 + 2;
    cc[aa].push_back(ni);
  }
  r[cc[11][0]] = 30;
  int pivot1, pivot2;
  if (Compare2(N, cc[1][0], cc[1][1]) == 1) {
    r[cc[1][0]] = 20;
    r[cc[1][1]] = 10;
    pivot1 = cc[1][1];
    pivot2 = cc[1][0];
  } else {
    r[cc[1][0]] = 10;
    r[cc[1][1]] = 20;
    pivot1 = cc[1][0];
    pivot2 = cc[1][1];
  }
  for (int i = 2; i <= 10; i++) {
    if (Compare2(N, cc[i][0], pivot1) == -1) {
      r[cc[i][0]] = i - 1;
      if (Compare2(N, cc[i][1], pivot2) == -1) {
        r[cc[i][1]] = i + 9;
        r[cc[i][2]] = i + 19;
      } else {
        r[cc[i][1]] = i + 19;
        r[cc[i][2]] = i + 9;
      }
    } else {
      if (Compare2(N, cc[i][1], pivot1) == -1) {
        r[cc[i][1]] = i - 1;
        if (Compare2(N, cc[i][2], pivot2) == -1) {
          r[cc[i][0]] = i + 19;
          r[cc[i][2]] = i + 9;
        } else {
          r[cc[i][0]] = i + 9;
          r[cc[i][2]] = i + 19;
        }
      } else {
        r[cc[i][2]] = i - 1;
        if (Compare2(N, cc[i][0], pivot2) == -1) {
          r[cc[i][0]] = i + 9;
          r[cc[i][1]] = i + 19;
        } else {
          r[cc[i][0]] = i + 19;
          r[cc[i][1]] = i + 9;
        }
      }
    }
  }
  std::vector<int> rr(N);
  for (int ni = 0; ni < N; ni++) {
    rr[ni] = r[ni];
  }
  return rr;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 644 KB Correct
2 Correct 9 ms 644 KB Correct
3 Correct 9 ms 644 KB Correct
4 Correct 9 ms 780 KB Correct
5 Incorrect 9 ms 756 KB Wrong
6 Halted 0 ms 0 KB -