#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] <= 24) res[i] = i / 4 + 1;
else res[i] = 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];
int KK;
int MyCompare(int x, int y)
{
if(x + 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;
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
taster.cpp: In function 'void Sort(std::vector<int>&)':
taster.cpp:33:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(v.size() < n)
~~~~~~~~~^~~
taster.cpp:35:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(j == B.size())
~~^~~~~~~~~~~
taster.cpp:37:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
else if(i == A.size())
~~^~~~~~~~~~~
taster.cpp: In function 'std::vector<int> SortWines(int, std::vector<int>)':
taster.cpp:65:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for(i=0; i<n; ++i)
^~~
taster.cpp:67:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
return ans;
^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
772 KB |
Correct |
2 |
Correct |
10 ms |
784 KB |
Correct |
3 |
Correct |
10 ms |
908 KB |
Correct |
4 |
Incorrect |
9 ms |
732 KB |
Wrong |
5 |
Halted |
0 ms |
0 KB |
- |