精神不佳,选择了在场外同步划水

没想到实际做起来手感还好,早知道就报名了……

该打

 

未完待续233

A. Andryusha and Socks

模拟,模拟大法好。注意每次是先判断完能不能收进柜子,再算桌子上的袜子数量的。

 

 1 /*by SilverN*/
 2 #include<iostream>
 3 #include<algorithm>
 4 #include<cstring>
 5 #include<cstdio>
 6 #include<cmath>
 7 using namespace std;
 8 const int mxn=100010;
 9 int read(){
10     int x=0,f=1;char ch=getchar();
11     while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
12     while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
13     return x*f;
14 }
15 int a[mxn],n;
16 int cnt[mxn];
17 int main(){
18     int i,j,x;
19     n=read();
20     int now=0,ans=0;
21     for(i=1;i<=n*2;i++){
22         x=read();
23         cnt[x]++;
24         now++;
25         if(cnt[x]==2)cnt[x]=0,now-=2;
26         ans=max(ans,now);
27     }
28     printf("%d\n",ans);
29     return 0;
30 }
A

相关文章: