let's say we don't build second one.

Then it's just simple to calculate **TimeWithoutBuild** using formula :

**TimeWithoutBuild = ceil(n/k)* t**

Now let's build the second and calculate the **TimeWithBuild**:

as it take **d** unit time to build, we first add **d** to **TimeWithBuild** now we might have already baked some cakes while building the second one. So we need to subtract that cakes from **n**, so our remaining cakes will be **n-(d/t)*k** let's say this is **n_rem** Now our speed of baking is doubled
So

**TimeWithBuild = d + ceil(n_rem/(2*k)) * t**

Now you will be good to code it yourself but nevertheless here is my solution....
Good Luck :p

View Content

Hide Content

#include<bits stdc++.h="">
using namespace std;
#define int long long
signed main(){
int n,t,k,d;
cin >> n >> t >> k >> d;
int T1 = t*( (n/k) + (n%k!=0));
int T2 = d + t*(( n-(d/t)*k )/(2*k) +(( n-(d/t)*k )%(2*k)!=0));
if(T2 < T1)puts("YES");
else puts("NO");
return 0;
}

answered
**24 Jun '18, 20:46**

4★meet2mky

201●3

accept rate:
28%