https://i1.wp.com/eblogarithm.com/wp-content/uploads/2017/11/Codeforces-Round-444-Div-2-problem-D-Ratings-and-Reality-Shows-Solution-In-CC.png?fit=640%2C360

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

#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;
}
change_rating-=(q[i]?c:-d);
Min-=(q[i]?c:-d);
rating+=(q[i]?a:-b);
if (rating<0)
{
printf(“-1\n”);
return 0;
}
}
printf(“%lld\n”,t[n]+1);
return 0;
}

(Visited 11 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: