Skip to content

Commit 1730234

Browse files
committed
tco 04 round 2 div 1 200 sol
1 parent a5975bd commit 1730234

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

SchoolAssembly.cpp

+3-24
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,8 @@ typedef vector<vs> vvs;
1818
class SchoolAssembly{
1919
public:
2020
int getBeans(int k, int q) {
21-
int x = 0, p = 0;
22-
int a[5] = {0, 0, 0, 0, 0};
23-
while(true){
24-
++x;
25-
int total = 20;
26-
for(int i = 0; i < 5; i++){
27-
int j = (p+i)%5;
28-
int a1 = a[j]%q;
29-
if(i == 4){
30-
p = j;
31-
a[j] += total;
32-
}
33-
else{
34-
if(total == 0) continue;
35-
int a2 = min(total, q-1-a1);
36-
a[j] += a2;
37-
total -= a2;
38-
}
39-
}
40-
int n = 0;
41-
for(int i = 0; i < 5; i++) n += a[i]/q;
42-
if(n >= k) return x;
43-
}
21+
//Max number of beans in each bucket so that the total number of sets of q beans of a particular colour is k
22+
return (k*q + 4*(q-1) + 19)/20;
4423
}
4524

4625
// BEGIN CUT HERE
@@ -64,4 +43,4 @@ int main(){
6443
SchoolAssembly ___test;
6544
___test.run_test(-1);
6645
}
67-
// END CUT HERE
46+
// END CUT HERE

0 commit comments

Comments
 (0)