답안 #247171

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
247171 2020-07-11T07:06:30 Z dantoh000 포도주 시음 (FXCUP4_wine) C++17
0 / 100
10 ms 780 KB
#include <bits/stdc++.h>
#include "bartender.h"
using namespace std;
vector<int> BlendWines(int K, vector<int> R){
	int N = R.size();
	vector<int> pos(N+1,0);
	int C = 0;
	int ct = 0;
	for (int i = 1; i <= N; i++){
        if (i == N) pos[i] = K;
        else{
            int dif = min(N-i,i);
            if (K-dif >= (K+1)/2) pos[i] = K-dif;
            else C++;
        }
	}

	for (int i = 1; i <= N; i++){
        if (pos[i] == 0){
            pos[i] = min((K-1)/2,ct/(C/(K/2))+1);
            ct++;
        }
	}
	for (int i = 1; i <= N; i++){
        //printf("%d ",pos[i]);
	}
	//printf("\n");
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        A[i] = pos[R[i]];
        //printf("%d ",A[i]);
    }
    //printf("\n");
	return A;
}
#include <bits/stdc++.h>
using namespace std;
#include "taster.h"
bool cmp(int a, int b){
    return Compare(a,b) == 1;
}
vector<int> SortWines(int K, vector<int> A) {
	int N = A.size();
	vector<int> pos[K+1];
	for (int i = 0; i < N ; i++){
        pos[A[i]].push_back(i);
	}
	vector<int> R(N);
	int l = 1, r = N;

	for (int i = K; i >= 1; i--){
        //printf("%d %d\n",i,pos[i].size());
        if (pos[i].size() == 1){
            R[pos[i][0]] = r--;
        }
        else if (i >= (K+1)/2){
            //printf("checking %d %d\n",pos[i][0],pos[i][1]);
            if (Compare(pos[i][0],pos[1][0]) == 1){
                R[pos[i][0]] = r--;
                R[pos[i][1]] = l++;
            }
            else{
                R[pos[i][1]] = r--;
                R[pos[i][0]] = l++;
            }
        }
        else{
            sort(pos[i].begin(),pos[i].end(),cmp);
            for (auto x : pos[i]){
                R[x] = r--;
            }
        }
	}
	for (int i = 0; i < N; i++){
        //printf("%d ",R[i]);
	}

	return R;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 780 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -