# Steaks-Codeforces Gym Problem(ArabellaCPC2019) Doubt

Question-https://codeforces.com/gym/102263/problem/H
My Solution-https://codeforces.com/gym/102263/submission/56275129
Problem-Getting Wrong Answer on test case 50.

My thinking-
I tried to find out logic for this problem by analyzing various cases of n and k and took out one observation from that for every n-k steaks it takes 5 minutes.

Can anyone help with this question?

logic is correct but i think you have not applied this condition :- if(time<10) time=10;

1 Like

Ohh good observation, wasn’t able to think about it
But, now it get’s wrong answer on test case 61. I think we are missing another thing also.

Here’s my code:
int main(){
int n,k;cin>>n>>k;
int cnt=0;
if(n%k==0) cnt=(n/k);
else cnt=(n/k)+1;
ll ans=cnt*5;
(ans>10)?(cout<<ans):(cout<<“10”);
return 0;

}

int main()
{
crap;
int n,k;
cin>>n>>k;
ll p=0;
while(n>0)
{
p+=5;
n=n-k;
}
if(p<10) p=10;
cout<<p<<endl;
}


This is the accepted solution. Division operator will give you wrong answer.

2 Likes

Your division should be like this:

# include <bits/stdc++.h>
using namespace std;

int main ()
{
long long n, k;
cin >> n >> k;
cout << max(10ll, (n + k - 1) / k * 5) << endl;
return 0;
}

2 Likes

Thanks bro, but any reason for that?

i have one doubt.

Tell you an identity:
\lceil\frac{n}{k} \rceil = \lfloor \frac{n + k - 1}{k} \rfloor

2 Likes

Then i think this should work also :- ceil(n/k);

1 Like

Wow. That would help
Thanks.

maybe not, I’ve always been cautious about floating-point numbers.

2 Likes

You’re very welcome.

1 Like

That’s why it is giving wrong answer by this way.
Can you provide any test case for which this would fail?

1 Like

I’m not sure, I always thought it depended on your luck.

2 Likes

oh , thank you for clearing it.

Can you explain me in the B problem
(https://codeforces.com/gym/102263/problem/B)
that how the second output is Kilani?

It’ easy to see.
If Kilani subtracts 2 for the first time, Ayoub can only subtract 1, so Kilani can win.

But k is given as 1

Can he subtracts max(1, m - k)?

oh!
Got it…
that was really stupid of me
(will just go and drown in shame)