Submission #247171

#TimeUsernameProblemLanguageResultExecution timeMemory
247171dantoh000Wine Tasting (FXCUP4_wine)C++17
0 / 100
10 ms780 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...