200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > Good Bye

Good Bye

时间:2020-02-22 23:19:26

相关推荐

Good Bye

**一年多没有搞ACM了,怀念原来沉浸在ACM的每时每刻,怀念它带给我的点点滴滴

--序言**

闲来无事想重温一下,发现思维有些卡顿了,以后还是要多做做cf,开拓思维。

C题:

题意:Limak参加了N场cf比赛,给出每一场的rating和,当场的division,问参加完N场之后,最多有多少分。

思路:从最后一场开始,如果当前参加的是div1,那么结束之后最小分为1900+当目前变化的总和;如果是div2,那么最大值就是1899+总和。

#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<map>#include<set>#include<queue>#include<stack>#include<string>#include<iterator>using namespace std;const int INF=0x3f3f3f3f;const int maxn=100010;const double eps=1e-8;int a[maxn],b[maxn];int N;int main(){while(cin>>N){for(int i=1;i<=N;i++)cin>>a[i]>>b[i];int sum=0;int maxv=INF,minv=-INF;for(int i=N;i>0;i--){sum+=a[i];if(b[i]==1){minv=max(minv,1900+sum);} else {maxv=min(maxv,1899+sum);}}if(minv>maxv)cout<<"Impossible"<<endl;else if(maxv==INF)cout<<"Infinity"<<endl;else cout<<maxv<<endl;}return 0;}

下面还有一个二分的做法,就是每次枚举开始值,然后判断是不是合法:codeforces Good Bye -C New Year and Rating(二分)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。
相关阅读
暑假  Good Bye!

暑假 Good Bye!

2021-10-18

Good Bye 题解

Good Bye 题解

2020-07-03

Good Bye  题解

Good Bye 题解

2024-07-27

Good Bye  题解

Good Bye 题解

2021-02-18