# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
150904 | Alexa2001 | Wine Tasting (FXCUP4_wine) | C++17 | 10 ms | 896 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 i, n = R.size();
vector<int> res(n);
for(i=0; i<n; ++i)
if(R[i] <= 23) res[i] = R[i] / 4 + 1;
else res[i] = R[i] - 17;
for(i=0; i<n; ++i)
if(res[i] > K) res[i] = K;
return res;
}
#include "taster.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> vec[30];
vector<int> alch;
int KK;
int MyCompare(int x, int y)
{
if(alch[x] + alch[y] <= KK) return Compare(x, y);
return -1;
}
void Sort(vector<int> &v)
{
int n = v.size();
if(n <= 1) return;
int mid = n / 2;
int i, j;
vector<int> A, B;
for(i=0; i<mid; ++i) A.push_back(v[i]);
for(; i<n; ++i) B.push_back(v[i]);
Sort(A); Sort(B);
v.clear();
i = 0; j = 0;
while(v.size() < n)
{
if(j == B.size())
v.push_back(A[i++]);
else if(i == A.size())
v.push_back(B[j++]);
else if(MyCompare(A[i], B[j]) == -1)
v.push_back(A[i++]);
else v.push_back(B[j++]);
}
}
vector<int> SortWines(int K, std::vector<int> A)
{
int n = A.size();
int i;
KK = K;
alch = A;
for(i=0; i<n; ++i)
vec[A[i]].push_back(i);
for(i=1; i<=12; ++i)
Sort(vec[i]);
vector<int> res;
for(i=1; i<=12; ++i)
for(auto it : vec[i])
res.push_back(it);
vector<int> ans(n);
for(i=0; i<n; ++i)
ans[res[i]] = i+1;
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |