Good Bye 2016 C. New Year and Rating 模拟

C. New Year and Rating

链接:

http://codeforces.com/contest/750/problem/C

代码:

 1 #include <map>
 2 #include <set>
 3 #include <cmath>
 4 #include <queue>
 5 #include <stack>
 6 #include <cstdio>
 7 #include <string>
 8 #include <vector>
 9 #include <cstring>
10 #include <iostream>
11 #include <algorithm>
12 #include <functional>
13 using namespace std;
14 #define rep(i,a,n) for (int i=a;i<=n;i++)
15 #define per(i,a,n) for (int i=n;i>=a;i--)
16 #define pb push_back
17 #define mp make_pair
18 #define all(x) (x).begin(),(x).end()
19 #define fi first
20 #define se second
21 #define SZ(x) ((int)(x).size())
22 typedef vector<int> VI;
23 typedef long long ll;
24 typedef pair<int, int> PII;
25 const ll mod = 1000000007;
26 const int inf = 0x3f3f3f3f;
27 const double eps = 1e-7;
28 // head
29 
30 int main() {
31     int n;
32     scanf("%d", &n);
33     int from = -inf, to = inf;
34     int delta = 0;
35     rep(i, 1, n) {
36         int d, cur;
37         scanf("%d %d", &cur, &d);
38         if (d == 1) from = max(from, 1900 - delta);
39         else to = min(to, 1899 - delta);
40         delta += cur;
41     }
42     if (from > to) return 0 * puts("Impossible");
43     if (to == inf) return 0 * puts("Infinity");
44     printf("%d\n", to + delta);
45     return 0;
46 }

 

posted @ 2017-02-23 14:05  Flowersea  阅读(179)  评论(0编辑  收藏  举报