# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
247136 | dantoh000 | Wine Tasting (FXCUP4_wine) | C++17 | 11 ms | 1036 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |