Submission #247136

#TimeUsernameProblemLanguageResultExecution timeMemory
247136dantoh000Wine Tasting (FXCUP4_wine)C++17
43 / 100
11 ms1036 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> A(N); for (int i = 0; i < N; i++){ if (R[i] == N) A[i] = K; else if (R[i] == N/2) A[i] = 1; else{ int dif = min(N-R[i],R[i]); A[i] = max(1,K-dif); } //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--){ if (pos[i].size() == 1){ R[pos[i][0]] = r--; } else if (pos[i].size() == 2){ 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...