https://i0.wp.com/eblogarithm.com/wp-content/uploads/2017/09/Codeforces-Round-436-Div-2-problem-C-Bus-Solution-In-CC1.png?fit=640%2C360

Codeforces Round #436 (Div. 2), problem: (C) Bus Solution In C/C++

#include <bits/stdc++.h>
using namespace std;
int main(){
int k,sum=0,end,cap,f,tank;
for(cin>>end>>cap>>f>>k,tank=cap;k–;f=end-f)
if(tank<f||cap<end-f) return cout<<-1,0;
else if(tank>=end+(k?end-f:0)) tank-=end;
else ++sum,tank=cap-(end-f);
cout<<sum;
}

(Visited 28 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: