Codeforces Round #444 (Div. 2), problem: (D) Ratings and Reality Shows Solution In C/C++

By |2017-11-07T20:05:57+00:00November 7th, 2017|Categories: C/C++, Programming|Tags: , , |

#include <cstdio> #include <algorithm> using namespace std; long long n,a,b,c,d,st,len,t[300010]; int q[300010]; int main() { scanf("%lld%lld%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d,&st,&len); for (int i=1;i<=n;i++) scanf("%lld%d",&t[i],&q[i]); t[0]=-1; int now=1; long long change_rating=0,Min=0,rating=st; for (int i=1;i<=n;i++) { while (now<=n&&t[now]-t[i]<len) { change_rating+=(q[now]?c:-d); Min=min(Min,change_rating); now++; } if (Min+rating>=0) { printf("%lld\n",t[i-1]+1); return 0; } [...]