CodeForces 567B-Berland National Library
来源:互联网 发布:关于windows格式化磁盘 编辑:程序博客网 时间:2024/05/21 07:33
CodeForces 567B-Berland National Library
题目大意:+代表有人进入,-代表有人出来,后面数字为编号,有的人可能一开始就在屋子里,写出在屋子里的最大容量至少为多少
解题思路:模拟,用o算现有人数,用max记录最大人数,加入出现未出现的编号出来就让max+1。
#include <stdio.h>#include <string.h>#include <math.h>#include <iostream>using namespace std;int main() { int n; char b; long long int s; long long int a[1000]; int x = 0; int max = 0; int o = 0; cin >> n; getchar(); while(n--) { b = getchar(); scanf("%lld", &s); getchar(); if(b == '-') { for(int i = 0; i <= x; i++) { if(i == x) { max++; break; } if(a[i] == s) { a[i] = -1; o--; break; } } } else if(b == '+') { o++; a[x] = s; x++; } if(o > max) max = o; } printf("%d\n", max); return 0;}
0 0
- CodeForces 567B-Berland National Library
- Codeforces 567B Berland National Library
- Codeforces 567 B. Berland National Library
- CodeForces 567B Berland National Library
- CodeForces 567B Berland National Library
- CodeForces 567B Berland National Library
- CodeForces - 567B Berland National Library
- CodeForces-567B Berland National Library
- CodeForces 567B Berland National Library
- Berland National Library CodeForces - 567B
- CodeForces 567B Berland National Library【思维】
- Codeforces B - Berland National Library
- CodeForces 567- Berland National Library
- CodeForces 567B Berland National Library 容器模拟
- codeforces(567A)--A. Lineland Mail--B. Berland National Library
- CodeForces 567B Berland National Library(模拟)(简单)
- B. Berland National Library
- Code Forces 567B Berland National Library
- Unity3D——使用UGUI制作小地图
- IDEA将web项目打成war包
- iOS9适配 之 关于info.plist 第三方登录 添加URL Schemes白名单
- ELK的搭建实践
- HyperPacer之获取产品帮助不求人
- CodeForces 567B-Berland National Library
- 查看网站黑链的几种方法
- HDOJ 5719 Arrange
- Android animation 基础
- BootStrap 的使用
- JSP的语法
- mysql中root用户的密码问题
- CodeForces 569A-Music
- 当rootViewController为tabbarController时,控制屏幕旋转的方法