Codeforces 750 C New Year and Rating
2017-06-04 13:55
399 查看
题目地址:http://codeforces.com/contest/750/problem/C
题意:就是按cf的Rating的规则来,每次cf的比赛有两个模块,分别是Div1(1900及以上),Div2(1900以下),题目会告诉你他经历了几场比赛,每次比赛所加(减)的分,以及比赛是哪种类型,让你求出他最后能得到的最高Rating,如果存在矛盾就输出“Impossible”,如果是无限分的话输出“Infinity”。
题解:因为如果下一场比赛是Div1的话他这次的初始分肯定是1900以上,如果是Div2的话他这次的初始分肯定是1900以下,所以先设最初的初始分为x,所以一定满足下面这种情况:
如果第i场比赛是div1: x >= 1900 - c1 - c2..ci
如果第i场比赛是div2: x <= 1899 - c1 - c2..ci
所以我们可以通过这种关系来判断,初始时他的分的范围是-inf ~ inf,然后每次按上述条件逼近范围,最后由最大范围的值+得的分的和(详细请见代码)
题意:就是按cf的Rating的规则来,每次cf的比赛有两个模块,分别是Div1(1900及以上),Div2(1900以下),题目会告诉你他经历了几场比赛,每次比赛所加(减)的分,以及比赛是哪种类型,让你求出他最后能得到的最高Rating,如果存在矛盾就输出“Impossible”,如果是无限分的话输出“Infinity”。
题解:因为如果下一场比赛是Div1的话他这次的初始分肯定是1900以上,如果是Div2的话他这次的初始分肯定是1900以下,所以先设最初的初始分为x,所以一定满足下面这种情况:
如果第i场比赛是div1: x >= 1900 - c1 - c2..ci
如果第i场比赛是div2: x <= 1899 - c1 - c2..ci
所以我们可以通过这种关系来判断,初始时他的分的范围是-inf ~ inf,然后每次按上述条件逼近范围,最后由最大范围的值+得的分的和(详细请见代码)
#include <iostream> #include <cstring> #include <string> #include <queue> #include <algorithm> #define inf 0x3f3f3f3f using namespace std; int main() { int n, mmax, mmin, sum; int a, b; cin.sync_with_stdio(false); while (cin >> n) { mmax = -inf;//左范围 mmin = inf;//右范围 be39 sum = 0; for (int i = 0; i < n; i++) { cin >> a >> b; if (b == 1) { mmax = max(mmax, 1900 - sum);//x >= 1900 - c1 - c2..ci } else { mmin = min(mmin, 1899 - sum);//x <= 1899 - c1 - c2..ci } sum += a; } if (mmin < mmax) {//因为左范围一定小于等于右范围 cout << "Impossible" << endl; } else if (mmin == inf) {//一直都是Div1,所以是无穷 cout << "Infinity" << endl; } else { cout << mmin + sum << endl; } } return 0; }
相关文章推荐
- codeforces 750-C. New Year and Rating(模拟)
- Codeforces Good Bye 2016 C. New Year and Rating(模拟)
- Codeforces 750 D New Year and Fireworks
- 【codeforces 750C】New Year and Rating(做法2)
- Codeforces Good Bye 2016 C.New Year and Rating//qduoj 三亿河老师的上分梦想
- 【Codeforces 750 B New Year and North Pole 】+ 手速
- 【Codeforces 750 D New Year and Fireworks】+ DFS
- 【codeforces 750C】New Year and Rating
- E - New Year and North Pole CodeForces - 750B(状态处理下就好了)
- codeforces 750A New Year and Hurry
- Codeforces Good Bye 2016 D. New Year and Fireworks(bfs/dfs)
- codeforces Good Bye 2015 D. New Year and Ancient Prophecy
- Codeforces-Good Bye 2017 C. New Year and Curling(计算几何)
- Codeforces Good Bye 2017 C. New Year and Curling(模拟水题)
- Good Bye 2016 C. New Year and Rating(二分)
- 【CodeForces】908 E. New Year and Entity Enumeration
- 【codeforces 750A】New Year and Hurry
- codeforces Good Bye 2015 E. New Year and Three Musketeers
- Codeforces-Good Bye 2017 B. New Year and Buggy Bot(模拟)
- CodeForces Good Bye 2016 :C New Year and Rating、D New Year and Fireworks、E New Year and Old Subsequ