Good Bye 2016 - C
题目链接:http://codeforces.com/contest/750/problem/C
题意:在CF中,每个人都有个Rank值。 当Rank>=1900时,为DIV1。Rank<1900时,为DIV2。现在给你参加每一场的DIV值和参加完这一层后的Rank值变化。问最大可能的初始Rank值。如果答案无限大输出Infinity,如果不可能出现输入的情况输出impossible。其他情况输出可能的最大答案。
思路:二分初始Rank值,然后在二分出来的初始Rank值在计算过程中发现分值在DIV1但是输入为DIV2表示初始分值高了,否则低了。
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<time.h>
#include<cmath>
using namespace std;
typedef long long int LL;
const int MAXN = 2e5 + ;
const int INF = 2e8;
struct Node{
int c, d;
}Contest[MAXN];
bool check(int x, int n){
LL Rank = x;
for (int i = ; i < n; i++){
if (Rank >= && Contest[i].d == ){ //高了
return true;
}
else if (Rank< && Contest[i].d == ){ //低了
return false;
}
else{
Rank += Contest[i].c;
}
}
return false;
}
int main(){
//#ifdef kirito
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
//#endif
// int start = clock();
int n;
while (scanf("%d", &n) != EOF){
for (int i = ; i < n; i++){
scanf("%d%d", &Contest[i].c, &Contest[i].d);
}
int L = -INF, R = INF, mid;
while (R >= L)
{
mid = (L + R) >> ;
if (check(mid, n)){
R = mid - ;
}
else{
L = mid + ;
}
}
if (R == INF){
printf("Infinity\n");
}
else{
LL ans = R; bool flag = true;
for (int i = ; i < n; i++){ //最后再判一遍是否与输入合法
if (ans >= && Contest[i].d == ){
flag = false;
}
else if (ans< && Contest[i].d == ){
flag = false;
}
else{
ans += Contest[i].c;
}
}
if (flag){
printf("%I64d\n", ans);
}
else{
printf("Impossible\n");
}
}
}
//#ifdef LOCAL_TIME
// cout << "[Finished in " << clock() - start << " ms]" << endl;
//#endif
return ;
}
Good Bye 2016 - C的更多相关文章
- codeforces Good bye 2016 E 线段树维护dp区间合并
codeforces Good bye 2016 E 线段树维护dp区间合并 题目大意:给你一个字符串,范围为‘0’~'9',定义一个ugly的串,即串中的子串不能有2016,但是一定要有2017,问 ...
- Good Bye 2016 A. New Year and Hurry【贪心/做题目每道题花费时间按步长为5等差增长,求剩余时间够做几道题】
A. New Year and Hurry time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces Good Bye 2016 E. New Year and Old Subsequence
传送门 题意: 给出一个长度为\(n\)的串,现在有\(q\)个询问,每个询问是一个区间\([l,r]\),要回答在区间\([l,r]\)中,最少需要删多少个数,满足区间中包含\(2017\)的子序列 ...
- Good Bye 2016
A - New Year and Hurry (water) #include <bits/stdc++.h> using namespace std; int main() { ]; ; ...
- Good Bye 2016 - D
题目链接:http://codeforces.com/contest/750/problem/D 题意:新年烟花爆炸后会往两端45°差分裂.分裂完后变成2部分,之后这2部分继续按这种规则分裂.现在给你 ...
- Good Bye 2016 - B
题目链接:http://codeforces.com/contest/750/problem/B 题意:地球的子午线长度为40000,两极点的距离为20000.现在你从北极出发,按照题目输入方式来走. ...
- Good Bye 2016 - A
题目链接:http://codeforces.com/contest/750/problem/A 题意:有n场比赛要打,第i场比赛需要花i*5分钟来完成,比赛从20:00开始.然后新年派对24:00开 ...
- Good Bye 2016 //智商再次下线,边界爆炸.....
A B很水就略了.. C.又是一次wannafly一样的判断区间的..... 边界设为2000000 正好GG...... fst的时候立马想到上次也是这么wa过的...... 所以下次遇到这种题 ...
- Codeforces Good Bye 2016 D 模拟搜索?
给出烟花的爆炸方式和爆炸次数 问最后有多少个格子会被炸到 如果dfs的话会超时... 利用模拟每一层来搜索..? 思想就是一开始有一个爆炸点向上 然后模拟完第一段 会产生一个爆炸点 朝两个方向 就用v ...
随机推荐
- Android之仿微信图片选择器
先上效果图.第一张图显示的是“相机”文件夹中的所有图片:通过点击多张图片可以到第二张图所示的效果(被选择的图片会变暗,同时选择按钮变亮):点击最下面的那一栏可以到第三张图所示的效果(显示手机中所有包含 ...
- Git 账户认证的一些问题
Mac被水浇了之后,只好用Window 开发了.但是在往Github上提交代码出现了些问题. 1. 提交时总是出现弹出框提示账号认证 之前Mac没有出现过这问题,所以有些怀疑Windows开发环境不友 ...
- ubuntu16.04(beaglebone) 下vim 和gcc 的信息
root@arm:~# dpkg -L gcc /. /usr /usr/bin /usr/bin/c99-gcc /usr/bin/c89-gcc /usr/share /usr/share/doc ...
- 关于TCP中的MSS
MSS 是TCP选项中最经常出现,也是最早出现的选项.MSS选项占4byte.MSS是每一个TCP报文段中数据字段的最大长度,注意:只是数据部分的字段,不包括TCP的头部.TCP在三次握手中,每一方都 ...
- 网络第二节——AFNworking
/** 要使用常规的AFN网络访问 AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; ...
- php curl 多线程方法
<?php /** * curl 多线程 * @param array $array 并行网址 * @param int $timeout 超时时间 * @return array */ fun ...
- SLF4J: Class path contains multiple SLF4J bindings.
库冲突导致的异常,由于多次引入SLF4j包导致. It seems you have several implementation of SLF4J; you should exclude all t ...
- Maven的Missing artifact问题解决
Maven的Missing artifact问题解决 今天在创建一个新的Maven项目时,在其中添加了很多依赖.刚开始为了避免错误就每添加一次,保存一下,Eclipse就会下载相应的包.最后为了 ...
- windows 平台 php_Imagick 拓展遇到的那些坑!
我的php环境是使用了phpstudy 下载地址:http://www.phpstudy.net/a.php/211.html 最终并未解决问题 持续更新~ 1.首先到官网上 http://www.i ...
- nodejs 笔记
安装环境----------------------------------------------------------------1,安装nodejs 起步------------------- ...