构造 Codeforces Round #Pi (Div. 2) B. Berland National Library
/*
题意:给出一系列读者出行的记录,+表示一个读者进入,-表示一个读者离开,可能之前已经有读者在图书馆
构造:now记录当前图书馆人数,sz记录最小的容量,in数组标记进去的读者,分情况讨论一下
*/
/************************************************
* Author :Running_Time
* Created Time :2015-8-6 0:23:37
* File Name :B.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int MAXN = 1e6 + ;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + ;
bool in[MAXN]; int main(void) { //Codeforces Round #Pi (Div. 2) B. Berland National Library
int n; scanf ("%d", &n);
memset (in, false, sizeof (in));
int now = , sz = ;
for (int i=; i<=n; ++i) {
char s[]; int x; scanf ("%s%d", &s, &x);
if (s[] == '+') {
now++; in[x] = true;
if (now > sz) sz++;
}
else if (s[] == '-') {
if (now == ) {
if (in[x]) in[x] = false;
sz++;
}
else {
if (!in[x]) { //是之前就进入图书馆的读者
sz++;
}
else {
in[x] = false; now--;
}
}
}
} printf ("%d\n", sz); return ;
}
构造 Codeforces Round #Pi (Div. 2) B. Berland National Library的更多相关文章
- 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 ...
- Codeforces Round #Pi (Div. 2) B. Berland National Library 模拟
B. Berland National LibraryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...
- Codeforces Round #Pi (Div. 2) B Berland National Library
B. Berland National Library time limit per test1 second memory limit per test256 megabytes inputstan ...
- map Codeforces Round #Pi (Div. 2) C. Geometric Progression
题目传送门 /* 题意:问选出3个数成等比数列有多少种选法 map:c1记录是第二个数或第三个数的选法,c2表示所有数字出现的次数.别人的代码很短,思维巧妙 */ /***************** ...
- 构造 Codeforces Round #302 (Div. 2) B Sea and Islands
题目传送门 /* 题意:在n^n的海洋里是否有k块陆地 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 输出完k个L后,之后全部输出S:) 5 10 的例子可以是这样的: LSLS ...
- 构造 Codeforces Round #310 (Div. 2) B. Case of Fake Numbers
题目传送门 /* 题意:n个数字转盘,刚开始每个转盘指向一个数字(0~n-1,逆时针排序),然后每一次转动,奇数的+1,偶数的-1,问多少次使第i个数字转盘指向i-1 构造:先求出使第1个指向0要多少 ...
- 暴力+构造 Codeforces Round #283 (Div. 2) C. Removing Columns
题目传送门 /* 题意:删除若干行,使得n行字符串成递增排序 暴力+构造:从前往后枚举列,当之前的顺序已经正确时,之后就不用考虑了,这样删列最小 */ /*********************** ...
- 贪心+构造 Codeforces Round #277 (Div. 2) C. Palindrome Transformation
题目传送门 /* 贪心+构造:因为是对称的,可以全都左一半考虑,过程很简单,但是能想到就很难了 */ /************************************************ ...
- 构造 Codeforces Round #275 (Div. 2) C. Diverse Permutation
题目传送门 /* 构造:首先先选好k个不同的值,从1到k,按要求把数字放好,其余的随便放.因为是绝对差值,从n开始一下一上, 这样保证不会超出边界并且以防其余的数相邻绝对值差>k */ /*** ...
随机推荐
- [NOIP2006] 提高组 洛谷P1063 能量项链
题目描述 在Mars星球上,每个Mars人都随身佩带着一串能量项链.在项链上有N颗能量珠.能量珠是一颗有头标记与尾标记的珠子,这些标记对应着某个正整数.并且,对于相邻的两颗珠子,前一颗珠子的尾标记一定 ...
- 贝尔数--Codeforces908E. New Year and Entity Enumeration
给n<=50个长度m<=1000的二进制数,记他们为集合T,求满足下面条件的集合S数:令$M=2^m-1$,1.$a \epsilon S \Rightarrow a \ \ xor \ ...
- css3 模拟标牌震荡效果
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...
- Ubuntu 16.04安装Intel显卡驱动(解决Intel HD Graphics 630显卡驱动问题)
一般Ubuntu都默认包含了Intel显卡的驱动,如果没有,那么先确定是不是显卡太高,比如I7第7代的CPU核显在Ubuntu 16.04中是没有的,导致画面会很卡,原因是Linux 4.4内核不包含 ...
- Hive之Order,Sort,Cluster and Distribute By
测试数据 create table sort_test( id int, name string ) row format delimited fields terminated by '\t' li ...
- Android GIS开发系列-- 入门季(12) 显示载天地图
在项目中可以经常需要动态加载一些图层,像投影地图服务.投影地图服务器.其实网上有大量这样的服务,比如天地图官网, . 随便点开一个服务,里面有相关的信息.那如何加载这样图层服务呢. 一.首先感谢这篇博 ...
- 改變iTunes備份路徑
*** 在任意分區建立文件夾用來移動iTunes原有備份 *** 例如:move"c:\user\vhd\appdata\roaming\apple computer"全部到&qu ...
- Storm计算结果是怎样存放的
Storm计算的结果存放在哪里? 刚開始接触Storm的时候.往往都会有这么一个疑问:"Storm处理后 的计算结果是保存在哪里呢?"是内存中还是在其他的地方? 官方给出的解释是: ...
- 自己定义ViewGroup控件(一)----->流式布局进阶(一)
main.xml <? xml version="1.0" encoding="utf-8"?> <com.example.SimpleLay ...
- Python爬虫开发【第1篇】【beautifulSoup4解析器】
CSS 选择器:BeautifulSoup4 Beautiful Soup 也是一个HTML/XML的解析器,主要的功能也是如何解析和提取 HTML/XML 数据. pip 安装:pip instal ...