Solution-
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
ll d1,v1,d2,v2,p,i,sum=0;
cin>>d1>>v1>>d2>>v2>>p;
for(i=1;i<=10000;i++)
{
if(d1<=i)
sum+=v1;
if(d2<=i)
sum+=v2;
if(sum>=p)
break;
}
cout<<i;
}
competitive programming guides eg.algorithms,problems,tricks ,datastructure based on cp.
Solution-
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
ll d1,v1,d2,v2,p,i,sum=0;
cin>>d1>>v1>>d2>>v2>>p;
for(i=1;i<=10000;i++)
{
if(d1<=i)
sum+=v1;
if(d2<=i)
sum+=v2;
if(sum>=p)
break;
}
cout<<i;
}
Comments
Post a Comment