# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
247137 | cheeheng | Wine Tasting (FXCUP4_wine) | C++17 | 11 ms | 1032 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 "bartender.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> BlendWines(int K, std::vector<int> R){
int N = R.size();
vector<int> A(N);
for(int i = 0; i < N; i ++){
A[i] = 0;
}
for(int i = 0; i < N; i ++){
if(R[i] <= 24){
A[i] = (R[i]+3)/4;
}else{
A[i] = R[i]-18;
}
}
return A;
}
#include "taster.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> SortWines(int K, std::vector<int> A) {
int N = A.size();
vector<int> ans(N);
for(int i = 0; i < N; i ++){
ans[i] = 0;
}
for(int i = 0; i < N; i ++){
if(A[i] >= 7){
ans[i] = A[i]+18;
}
}
for(int k = 1; k <= 6; k ++){
vector<int> possible1;
for(int i = 0; i < N; i ++){
if(A[i] == k){
possible1.push_back(i);
}
}
if(possible1.empty()){break;}
vector<int> order;
order.push_back(possible1[0]);
//order.push_back(0);
for(int j = 1; j <= (int)possible1.size()-1; j ++){
int lo = 0;
int hi = j;
while(lo < hi){
//printf("%d %d\n", lo, hi);
int mid = (lo+hi+1)>>1;
if(Compare(order[mid-1], possible1[j]) == -1){
lo = mid;
}else{
hi = mid-1;
}
}
order.insert(order.begin()+lo, possible1[j]);
}
for(int j = 0; j < (int)order.size(); j ++){
//printf("%d ", order[j]);
ans[order[j]] = 1 + (k-1)*4 + j;
}
for(int j = 0; j < (int)order.size(); j ++){
//printf("ans[%d]=%d\n", order[j], ans[order[j]]);
}
//printf("\n");
}
//printf("ans[%d]=%d\n", 0, ans[0]);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |