Getting wrong answer in College Life 4 (March long-challenge 2021)

#include<bits/stdc++.h>
using namespace std;
#define li long long
int main(){
li t;
cin >> t;
while(t–>0){
li n,e,h,a,b,c,temp,cakes=0,shakes=0,omletes=0;
cin >> n >> e >> h >> a >> b >> c;
li left = n,cost = 1e18;
temp = min(min(e,h),left); left -= temp; cakes = temp;
temp = min((h-cakes)/3,left); left -= temp;
temp = min((e-cakes)/2,left); left -= temp;
if(left > 0){
cout << -1 << “\n”;
continue;
}
shakes = min(h/3,n); cakes = 0;
while(shakes>=0){
if(a > c){
cakes = min(min(e,h-shakes3),n-shakes);
omletes = min((e-cakes)/2,n-cakes-shakes);
}else{
omletes = min(e/2,n-shakes);
cakes = min(min(e-omletes
2,h-shakes3),n-omletes-shakes);
}
if(cakes + omletes + shakes == n)
cost = min(a
omletes+bshakes+ccakes,cost);
shakes–;
}
cout << cost << “\n”;
}
}

Your code is failing these test cases
2
6 4 11 5 1 4
6 20 11 8 3 6
Expected o/p :
16
29
Your o/p :
18
30

Thank you! , I’ve rectified it and got an AC with a little help from youtube. When I put Cakes as constant it gives AC, but when I put milkshakes as constant it gives a WA, could you suggest any test cases that my code is failing.

1 Like

Your code fails in these testcases
5
6 7 5 1 1 1
2 5 5 1 3 2
4 5 5 1 4 2
4 5 6 1 4 3
4 4 5 1 4 3
Expected O/P :
6
2
7
9
11
Your O/P :
1000000000000000000
2
8
9
1000000000000000000

1 Like