这类题一个操作增加多少,一个操作减少多少,求最少刚开始为多少,在中途不会出现负值,模拟一遍,用一个数记下最大的即可

 #include<cstdio>
#include<cstring> const int HASH=; int n,num[],head[HASH],next[]; void insert(int s)
{
int h=num[s]%HASH;
int u=head[h];
while(u) u=next[u];
next[s]=head[h];//原来的链表头成为s的next
head[h]=s;//s成为head[h]的链表头
} int erase(int s)
{
int h=num[s]%HASH;
int u=head[h];
while(u)
{
if(num[u]==num[s])
{
num[u]=;
return ;
}
u=next[u];
}
return ;
} int main()
{
while(scanf("%d",&n)==)
{
int x,cap=,j=,maxcap=;
char op[];
memset(head,,sizeof(head));
for(int i=;i<=n;i++)
{
scanf("%s%d",op,&num[j]);
if(op[]=='+')
{
insert(j);
j++;
cap++;
//printf("cap=%d\n",cap);
if(cap>maxcap) maxcap=cap;
}
else
{
if(erase(j)) cap--;
else maxcap++;//在记下maxcap之前已经在里面
//printf("cap=%d\n",cap);
if(cap>maxcap) maxcap=cap;
}
}
printf("%d\n",maxcap);
}
return ;
}
 #include<cstdio>
#include<cstring> int T,n,a,b,L,cas=; int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d%d%d%d",&n,&a,&b,&L);
int l,r,strength=,min=,last=;
for(int i=;i<n;i++)
{
scanf("%d%d",&l,&r);
strength+=b*(l-last)-a*(r-l);
if(strength<min) min=strength;
last=r;
}
printf("Case #%d: %d\n",cas++,-min);
}
return ;
}

CodeForces 567B Berland National Library hdu-5477 A Sweet Journey的更多相关文章

  1. CodeForces 567B Berland National Library

    Description Berland National Library has recently been built in the capital of Berland. In addition, ...

  2. Codeforces B - Berland National Library

    B. Berland National Library time limit per test 1 second memory limit per test 256 megabytes input s ...

  3. HDU 5477 A Sweet Journey 水题

    A Sweet Journey Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pi ...

  4. HDU 5477: A Sweet Journey

    A Sweet Journey Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  5. Codeforces 567B:Berland National Library(模拟)

    time limit per test : 1 second memory limit per test : 256 megabytes input : standard input output : ...

  6. Codeforces Round #Pi (Div. 2) B. Berland National Library set

    B. Berland National LibraryTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...

  7. Codeforces Round #Pi (Div. 2) B. Berland National Library 模拟

    B. Berland National LibraryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...

  8. 构造 Codeforces Round #Pi (Div. 2) B. Berland National Library

    题目传送门 /* 题意:给出一系列读者出行的记录,+表示一个读者进入,-表示一个读者离开,可能之前已经有读者在图书馆 构造:now记录当前图书馆人数,sz记录最小的容量,in数组标记进去的读者,分情况 ...

  9. Codeforces Round #Pi (Div. 2) B Berland National Library

    B. Berland National Library time limit per test1 second memory limit per test256 megabytes inputstan ...

随机推荐

  1. Python 逻辑行/物理行

    物理行是你在编写程序时所看见的. 逻辑行是Python看见的单个语句.Python假定每个物理行对应一个逻辑行 . 默认地,Python希望每行都只使用一个语句,这样使得代码更加易读. 如果你想要在一 ...

  2. zookeeper(1)

    参考文档:zookeeper中文网 一.介绍安装 zookeeper 是一个高效的分布式协调服务,它暴露了一些公用服务,比如命名/配置/同步控制/群组服务等.我们可以使用ZK来实现一些功能,例如:达成 ...

  3. MySQL事务内幕与ACID

    MySQL的事务实现严格遵循ACID特性,即原子性(atomicity),一致性(consistency),隔离性(isolation),持久性(durability).为了避免一上来就陷入对ACID ...

  4. 关于解决“No matching provisioning profiles found”问题-ios

    xcode7之后真机调试就可以不需要调试证书了,但其中也会遇到一些问题令人挠头搔耳.记录下来是给自己提供方便,也为初遇到此问题的人提供解答,利人利己的事情我做!   上图: 图一 本人有一种视警号为e ...

  5. javascript焦点图之缓冲滚动无缝切换

    在用于实现无缝切换四张图,所以设置了6个图片就是 4,0,1,2,3,4,0 <!DOCTYPE html> <html> <head> <meta char ...

  6. C#第六天

    字符串的处理练习: 课上练习1:接收用户输入的字符串,将其中的字符以与输入相反的顺序输出."abc"→"cba" 方法1: string str = " ...

  7. Java--重载与重写

    父类(Parent): public class Parent { public String name = "parent 父类属性"; public void say(){ S ...

  8. sql语句的group by与having子句

    准备数据: DROP TABLE IF EXISTS `t_player`; CREATE TABLE `t_player` ( `player_id` int(11) NOT NULL AUTO_I ...

  9. HDU2544-最短路(最短路模版题目)

    Problem Description 在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt.但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要 ...

  10. 解决ie阴影的兼容性

    box-shadow:0px 0px 10px #aba25b; -webkit-box-shadow:0px 0px 10px #aba25b; -moz-box-shadow:0px 0px 10 ...