#include "bartender.h"
using namespace std;
vector<int> BlendWines(int K, vector<int> R) {
int N = R.size(), L = max(0, N - 27);
vector<int> V;
vector<int> X;
for(int i=0;i<N;i++) {
V.push_back(0);
if(R[i] >= 27) {
X.push_back(R[i] - 26);
V[i] = 10;
}
}
for(int i=L+1;i<=9;i++) {
X.push_back(i);
}
for(int i=0;i<N;i++) {
if(V[i] == 10) continue;
V[i] = X[R[i] % 9];
}
return V;
}
#include "taster.h"
using namespace std;
vector<int> val[15], tens;
void sortA (vector<int> &V) {
for(int i=0;i<V.size();i++) {
for(int j=i-1;j>=0;j--) {
if(Compare(V[j], V[j+1]) == 1) swap(V[j], V[j+1]);
else break;
}
}
}
void sortB (vector<int> &V, vector<int> &T) {
vector<int> R;
for(int i=0;i<V.size();i++) R.push_back(-1);
for(int i=0;i<V.size();i++) {
for(int j=0;j<V.size();j++) {
if(j+1 == V.size() || (R[j] == -1 && Compare(T[j+1], V[i]) == 1)) {
R[j] = V[i];
break;
}
}
}
swap(R, V);
}
vector<int> SortWines(int K, vector<int> A) {
int N = A.size(), L = 0;
vector<int> R;
for(int i=0;i<N;i++) {
R.push_back(0);
if(A[i] == 10) {
tens.push_back(i);
L++;
}
else {
val[A[i]].push_back(i);
}
}
vector<int> hds;
for(int i=1;i<=L;i++) {
sortA(val[i]);
hds.push_back(val[i][0]);
}
sortA(hds);
for(int i=0;i<hds.size();i++) {
int T = A[hds[i]];
R[tens[i]] = 26 + T;
for(int j=0;j<val[T].size();j++) {
R[val[T][j]] = j * 9 + i;
}
}
for(int i=L+1;i<=9;i++) {
sortB(val[i], val[1]);
for(int j=0;j<val[i].size();j++) {
R[val[i][j]] = j * 9 + i - 1;
}
}
return R;
}
Compilation message
taster.cpp: In function 'void sortA(std::vector<int>&)':
taster.cpp:7:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<V.size();i++) {
~^~~~~~~~~
taster.cpp: In function 'void sortB(std::vector<int>&, std::vector<int>&)':
taster.cpp:17:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<V.size();i++) R.push_back(-1);
~^~~~~~~~~
taster.cpp:18:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<V.size();i++) {
~^~~~~~~~~
taster.cpp:19:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<V.size();j++) {
~^~~~~~~~~
taster.cpp:20:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(j+1 == V.size() || (R[j] == -1 && Compare(T[j+1], V[i]) == 1)) {
~~~~^~~~~~~~~~~
taster.cpp: In function 'std::vector<int> SortWines(int, std::vector<int>)':
taster.cpp:48:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<hds.size();i++) {
~^~~~~~~~~~~
taster.cpp:51:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<val[T].size();j++) {
~^~~~~~~~~~~~~~
taster.cpp:57:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<val[i].size();j++) {
~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
644 KB |
Correct |
2 |
Correct |
8 ms |
644 KB |
Correct |
3 |
Correct |
10 ms |
780 KB |
Correct |
4 |
Incorrect |
9 ms |
804 KB |
Wrong |
5 |
Halted |
0 ms |
0 KB |
- |