CF #403 Div.2 A

本文探讨了一个有趣的算法问题:有序男孩安德留沙如何将成对的袜子整理放入衣柜,并在此过程中确保桌面袜子数量的最大值。通过分析输入顺序及配对规则,实现了对最大桌面袜子数的有效计算。
A. Andryusha and Socks
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 from1 ton. 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?

Input

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 thei-th sock Andryusha took out was from pairxi.

It is guaranteed that Andryusha took exactly two socks of each pair.

Output

Print single integer — the maximum number of socks that were on the table at the same time.

Examples
Input
1
1 1
Output
1
Input
3
2 1 1 3 2 3
Output
2
Note

In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time.

In the second example Andryusha behaved as follows:

  • Initially the table was empty, he took out a sock from pair 2 and put it on the table.
  • Sock (2) was on the table. Andryusha took out a sock from pair1 and put it on the table.
  • Socks (1, 2) were on the table. Andryusha took out a sock from pair1, and put this pair into the wardrobe.
  • Sock (2) was on the table. Andryusha took out a sock from pair3 and put it on the table.
  • Socks (2, 3) were on the table. Andryusha took out a sock from pair2, and put this pair into the wardrobe.
  • Sock (3) was on the table. Andryusha took out a sock from pair3 and put this pair into the wardrobe.
Thus, at most two socks were on the table at the same time.
#include<iostream>
#include<cstdio>
#include<string.h>
#include<algorithm>
#define LL long long 
#define MAX 200010
using namespace std;

int a[MAX];
int main()
{
	
	int n;
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++)
		a[i]=2;
	int tab=0;
	int ans=0;
	for(int i=1;i<=2*n;i++)
	{
		int c;
		scanf("%d",&c);
		a[c]-=1;
		if(a[c]==1)
		{
			tab++;
			ans=max(ans,tab);
		}
		else
		{
			tab--;
		}
	} 
	printf("%d\n",ans);
	
}

内容概要:本文介绍了ENVI Deep Learning V1.0的操作教程,重点讲解了如何利用ENVI软件进行深度学习模型的训练与应用,以实现遥感图像中特定目标(如集装箱)的自动提取。教程涵盖了从数据准备、标签图像创建、模型初始化与训练,到执行分类及结果优化的完整流程,并介绍了精度评价与通过ENVI Modeler实现一键化建模的方法。系统基于TensorFlow框架,采用ENVINet5(U-Net变体)架构,支持通过点、线、面ROI或分类图生成标签数据,适用于多/高光谱影像的单一类别特征提取。; 适合人群:具备遥感图像处理基础,熟悉ENVI软件操作,从事地理信息、测绘、环境监测等相关领域的技术人员或研究人员,尤其是希望将深度学习技术应用于遥感目标识别的初学者与实践者。; 使用场景及目标:①在遥感影像中自动识别和提取特定地物目标(如车辆、建筑、道路、集装箱等);②掌握ENVI环境下深度学习模型的训练流程与关键参数设置(如Patch Size、Epochs、Class Weight等);③通过模型调优与结果反馈提升分类精度,实现高效自动化信息提取。; 阅读建议:建议结合实际遥感项目边学边练,重点关注标签数据制作、模型参数配置与结果后处理环节,充分利用ENVI Modeler进行自动化建模与参数优化,同时注意软硬件环境(特别是NVIDIA GPU)的配置要求以保障训练效率。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值