huangyu's blog

By huangyu, history, 9 years ago, In English

http://codeforces.me/problemset/problem/780/A 这题目难点在于设置bool数组 袜子存进去就设置为true

###

#include <bits/stdc++.h>
using namespace std;
bool a[100000];
int main()
{
    int n,sum=0,al=0;
    memset(a,false,100000);
    cin>>n;
    int t;
    for(int i=0;i<2*n;i++){
        cin>>t;
        if(!a[t]){
            sum++;
            al=max(al,sum);
            a[t]=true;
        }
        else
            sum--;

    }
    cout<<al<<endl;
    return 0;
}
  • Vote: I like it
  • -23
  • Vote: I do not like it

| Write comment?
»
9 years ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

What are you doing???