CF782A Andryusha and Socks
题意:
Andryusha is an orderly boy and likes to keep things in their place.
Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe.
Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time?
The first line contains the single integer n (1 ≤ n ≤ 105) — the number of sock pairs.
The second line contains 2n integers x1, x2, ..., x2n (1 ≤ xi ≤ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi.
It is guaranteed that Andryusha took exactly two socks of each pair.
Print single integer — the maximum number of socks that were on the table at the same time.
1
1 1
1
3
2 1 1 3 2 3
2
思路:
水题不解释。
实现:
#include <cstdio>
#include <iostream>
using namespace std;
int cnt[], tmp, n;
int main()
{
cin >> n;
int all = ;
int maxn = -;
for (int i = ; i < * n; i++)
{
cin >> tmp;
cnt[tmp]++;
if (cnt[tmp] == )
all--;
else
all++;
if (maxn < all)
maxn = all;
}
cout << maxn << endl;
return ;
}
CF782A Andryusha and Socks的更多相关文章
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) A. Andryusha and Socks
地址:http://codeforces.com/contest/782/problem/A 题目: A. Andryusha and Socks time limit per test 2 seco ...
- AC日记——Andryusha and Socks Codeforces 780a
A. Andryusha and Socks time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- 【codeforces 782A】Andryusha and Socks
[题目链接]:http://codeforces.com/contest/782/problem/A [题意] 如果手套没有成一双,那么其中的一只就会被放在桌子上; 问你桌子上手套的只数最多的时候有几 ...
- cf 782# A.Andryusha and Socks B.The Meeting Place Cannot Be Changed C.Andryusha and Colored Balloons
看来快掉到灰名的蒟蒻涨rating也快... A题模拟一下就好(一开始还sb,, #include<bits/stdc++.h> #define LL long long using na ...
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)
Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放 ...
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)A模拟 B三分 C dfs D map
A. Andryusha and Socks time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- CodeForces Round #403 (Div.2) A-F
精神不佳,选择了在场外同步划水 没想到实际做起来手感还好,早知道就报名了…… 该打 未完待续233 A. Andryusha and Socks 模拟,模拟大法好.注意每次是先判断完能不能收进柜子,再 ...
- iphone使用mac上的SOCKS代理
Step 1. Make sure the SOCKS tunnel on your work computer allows LAN connections so your iPhone/iPod ...
- CF731C. Socks[DFS 贪心]
C. Socks time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...
随机推荐
- IE9不能直接引用Console
问题: 公司有个项目,功能很简单,读取业务数据,展示在页面上. 一个很简单的问题,却因为目标浏览器是IE9,卡了三天. 前端给的反馈是: 在IE9下,程序一会儿对,一会儿不对--第一次刷不出来,多刷几 ...
- python中list用法及遍历删除元素
列表(list)是python的基本数据结构,list中每一个元素都分配一个位置索引,可以通过索引访问元素值,list不要求数据项有相同的数据类型. list初始化 list由一个方括号加内部由逗号分 ...
- 聊聊Spring中的工厂
BeanFactory是Spring IOC容器的根接口,定义了Bean工厂的最基础的功能特性,比如根据name获取指定bean等,根据不同用途它的子接口又对它的功能进行细化,比如是否是可列表的,是否 ...
- Linux Cache 机制
在阅读文章前,您应该具备基本的存储器层次结构知识,至少要了解局部性原理.要详细了解cache基本原理,可以参考本书<深入理解计算机系统>中存储器体系结构一章: 带着疑问来看文章,cache ...
- Laravel 新增的Switch模板控制语句非常不错
切换语句switch语句可以使用来构建,,,和指令:@switch@case@break@default@endswitch @switch($i) @case(1) First case... @b ...
- "standard,singleTop,singleTask,singleInstance"-Android启动模式
安卓有4种启动模式,下面我们就进行详细的讲解 用栈的思维去理解,就能理解这些启动模式的本质了 先设置两个页面: A(为测试对象),B两个页面,两个页面都有跳至对方的按钮 一.标准模式(standard ...
- eclipse配置环境基本设置
一.修改字符集编码 二修改字体 三.安装jre 四.修改jsp文件的默认字符集 五.展示想要的窗口 六.修改右键new的内容
- 任务39:Role以及Claims授权
基于Role角色的授权 asp.net core在逐渐淘汰这种基于RoleBase的基于角色的授权.鼓励大家使用基于Claim的授权 在认证的时候Cliam已经加入了Role 注释38节课的 自定义验 ...
- c语言基本数据类型相关
1byte = 8bit 数据类型 比特长度 位长度 IO表达 int 2/4 16/32 %d unsigned (int) 2/4 16/32 %u short int ...
- 51nod1127【尺取】
思路: 尺取,写挫了,debug了半天. #include <bits/stdc++.h> using namespace std; typedef long long LL; const ...