#include "bartender.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> BlendWines(int K, vector<int> R){
if(K < 11) assert(false);
vector<int> ans;
for(int x : R){
int grp = ((x-1) / 6);
grp++;
if((x-1) % 6 == 0 || (x-1) % 6 == 5){
ans.push_back(11-grp);
}
else ans.push_back(grp);
}
return ans;
}
#include "taster.h"
#include <bits/stdc++.h>
using namespace std;
int n;
int cmp(int a, int b){
//cout << "Q: " << a << " " << b << "\n";
if(a >= n && b >= n){
if(a < b) return -1;
else return 1;
}
if(a >= n) return 1;
if(b >= n) return -1;
int res= Compare(a,b);
//cout << res << "\n";
return res;
}
vector<int> SortWines(int K, vector<int> A) {
n = A.size();
while(A.size() < 30){
int x = A.size()+1;
int grp = ((x-1) / 6);
grp++;
if((x-1) % 6 == 0 || (x-1) % 6 == 5){
A.push_back(11-grp);
}
else A.push_back(grp);
}
//for(int i : A) cout << i << " ";
vector<int> res;
for(int i = 0;i < 30;i++) res.push_back(0);
for(int f = 1;f <= 5;f++){
vector<int> v;
for(int i = 0;i < 30;i++){
if(A[i] == f) v.push_back(i);
}
//cout << v[0] << " " << v[1] << " " << v[2] << " " << v[3] << "\n";
if(cmp(v[0], v[1]) == 1) swap(v[0], v[1]);
if(cmp(v[2], v[3]) == 1) swap(v[2], v[3]);
if(cmp(v[0], v[2]) == 1) swap(v[0], v[2]);
if(cmp(v[1], v[3]) == 1) swap(v[1], v[3]);
if(cmp(v[1], v[2]) == 1) swap(v[1], v[2]);
//cout << v[0] << " " << v[1] << " " << v[2] << " " << v[3] << "\n";
for(int i = 0;i < 4;i++){
res[v[i]] = (f-1)*6 + i + 2;
}
int small = (f-1)*6 + 1;
int big = (f-1)*6 + 6;
vector<int> o;
for(int i = 0;i < 30;i++){
if(A[i] == 11-f) o.push_back(i);
}
if(cmp(o[0], v[0]) == 1) swap(o[0], o[1]);
res[o[0]] = small;
res[o[1]] = big;
}
while((int) res.size() > n) res.pop_back();
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
780 KB |
Correct |
2 |
Correct |
8 ms |
776 KB |
Correct |
3 |
Correct |
9 ms |
792 KB |
Correct |
4 |
Correct |
8 ms |
784 KB |
Correct |
5 |
Correct |
10 ms |
780 KB |
Correct |
6 |
Correct |
9 ms |
780 KB |
Correct |
7 |
Correct |
8 ms |
780 KB |
Correct |
8 |
Correct |
8 ms |
784 KB |
Correct |
9 |
Correct |
9 ms |
992 KB |
Correct |
10 |
Correct |
10 ms |
1016 KB |
Correct |
11 |
Correct |
10 ms |
776 KB |
Correct |
12 |
Correct |
9 ms |
780 KB |
Correct |
13 |
Correct |
10 ms |
788 KB |
Correct |
14 |
Correct |
9 ms |
1016 KB |
Correct |
15 |
Correct |
9 ms |
784 KB |
Correct |
16 |
Correct |
10 ms |
880 KB |
Correct |
17 |
Correct |
10 ms |
784 KB |
Correct |
18 |
Correct |
9 ms |
1016 KB |
Correct |
19 |
Correct |
9 ms |
776 KB |
Correct |
20 |
Correct |
9 ms |
888 KB |
Correct |
21 |
Correct |
9 ms |
784 KB |
Correct |
22 |
Correct |
9 ms |
788 KB |
Correct |
23 |
Correct |
9 ms |
1036 KB |
Correct |
24 |
Correct |
10 ms |
812 KB |
Correct |
25 |
Correct |
9 ms |
912 KB |
Correct |
26 |
Correct |
9 ms |
1024 KB |
Correct |
27 |
Correct |
10 ms |
776 KB |
Correct |
28 |
Correct |
10 ms |
912 KB |
Correct |
29 |
Correct |
9 ms |
896 KB |
Correct |
30 |
Correct |
9 ms |
784 KB |
Correct |
31 |
Correct |
8 ms |
648 KB |
Correct |
32 |
Correct |
9 ms |
648 KB |
Correct |
33 |
Correct |
9 ms |
648 KB |
Correct |
34 |
Correct |
9 ms |
776 KB |
Correct |
35 |
Correct |
9 ms |
884 KB |
Correct |
36 |
Correct |
9 ms |
776 KB |
Correct |
37 |
Correct |
10 ms |
912 KB |
Correct |
38 |
Correct |
9 ms |
896 KB |
Correct |
39 |
Correct |
9 ms |
776 KB |
Correct |
40 |
Correct |
10 ms |
784 KB |
Correct |
41 |
Correct |
9 ms |
776 KB |
Correct |
42 |
Correct |
10 ms |
776 KB |
Correct |
43 |
Correct |
9 ms |
912 KB |
Correct |
44 |
Correct |
9 ms |
776 KB |
Correct |
45 |
Correct |
9 ms |
776 KB |
Correct |
46 |
Correct |
9 ms |
788 KB |
Correct |
47 |
Correct |
9 ms |
648 KB |
Correct |
48 |
Correct |
10 ms |
1008 KB |
Correct |
49 |
Correct |
10 ms |
780 KB |
Correct |
50 |
Correct |
10 ms |
776 KB |
Correct |
51 |
Correct |
10 ms |
884 KB |
Correct |
52 |
Correct |
10 ms |
1012 KB |
Correct |
53 |
Correct |
9 ms |
784 KB |
Correct |
54 |
Correct |
9 ms |
792 KB |
Correct |
55 |
Correct |
9 ms |
776 KB |
Correct |
56 |
Correct |
10 ms |
784 KB |
Correct |
57 |
Correct |
10 ms |
788 KB |
Correct |
58 |
Correct |
9 ms |
792 KB |
Correct |
59 |
Correct |
9 ms |
884 KB |
Correct |
60 |
Correct |
9 ms |
788 KB |
Correct |
61 |
Correct |
8 ms |
788 KB |
Correct |
62 |
Correct |
9 ms |
648 KB |
Correct |
63 |
Correct |
8 ms |
784 KB |
Correct |
64 |
Correct |
8 ms |
784 KB |
Correct |
65 |
Correct |
9 ms |
1012 KB |
Correct |
66 |
Correct |
10 ms |
892 KB |
Correct |
67 |
Correct |
9 ms |
784 KB |
Correct |
68 |
Correct |
8 ms |
780 KB |
Correct |
69 |
Correct |
9 ms |
776 KB |
Correct |
70 |
Correct |
8 ms |
780 KB |
Correct |
71 |
Correct |
9 ms |
780 KB |
Correct |
72 |
Correct |
9 ms |
784 KB |
Correct |
73 |
Runtime error |
6 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
74 |
Halted |
0 ms |
0 KB |
- |