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

 #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. 聊天系统Demo,增加文件传送功能(附源码)-- ESFramework 4.0 快速上手(14)

    本文我们将介绍在ESFramework 4.0 快速上手(08) -- 入门Demo,一个简单的IM系统(附源码)的基础上,增加文件传送的功能.如果不了解如何使用ESFramework提供的文件传送功 ...

  2. 理解php的opcode

    Opcode是一种PHP脚本编译后的中间语言,就像Java的ByteCode,或者.NET的MSL,举个例子,比如你写下了如下的PHP代码: <?php echo "Hello Wor ...

  3. vs2015打开cshtml文件失败的解决方法

    最近不知道为什么,用vs2015打开cshtml识图文件的时候会报错.也不知道是什么原因,google之后得到解决方法如下: Close VS Delete the content of %Local ...

  4. Gentoo网络配置

    网卡识别配置 要开始配置你的网卡,你首先需要告诉Gentoo RC系统你的网卡. 可以用ifconfig命令查看自己网卡名字: ifconfig -a 网卡名字(如eth0)的识别是通过在/etc/i ...

  5. iOS UITextView 根据输入text自适应高度

    转载自:http://www.cnblogs.com/tmf-4838/p/5380495.html #import "ViewController.h" @interface V ...

  6. drupal7 开发block

    在自己开发的模块的module文件中,实现两个钩子:hook_block_info()和hook_block_view() function journal_block_info() { $block ...

  7. Yii2.0 多条件搜索 带分页

                                   方法一   在控制器中 ; if($titles!=""){ $where.=" and title lik ...

  8. 在CentOS7部署zookeeper集群以及简单API使用

    一.部署zookeeper集群 zookeeper是一个针对大型分布式系统的协调系统,提供的功能有统一名称服务.分布式同步等. 1.上传zk安装包 2.解压     tar -xzvf zookeep ...

  9. 正则表达式判断ip地址

    html: <div class="configuration"><form action="" name="myformcon&q ...

  10. Python基础学习笔记---5.输入\输出 I\O文件操作目录

    在很多时候,你会想要让你的程序与用户(可能是你自己)交互.你会从用户那里得到输入,然后打印一些结果.我们可以分别使用 raw_input 和 print 语句来完成这些功能.对于输出,你也可以使用多种 ...