Skip to content

Instantly share code, notes, and snippets.

@vovuh
Created August 7, 2015 18:34
Show Gist options
  • Save vovuh/674625f2f04c58b0e01f to your computer and use it in GitHub Desktop.
Save vovuh/674625f2f04c58b0e01f to your computer and use it in GitHub Desktop.
#define _CRT_SECURE_NO_WARNINGS
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <time.h>
#include <string>
#include <vector>
#include <math.h>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
#define ft first
#define sc second
#define mp make_pair
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
typedef long long li;
typedef long double ld;
typedef pair <li, li> pli;
typedef pair <int, int> pii;
const int N = 1000100;
int n;
bool in[N];
int main()
{
cin >> n;
int mx = 0, tx = 0;
forn(i, n)
{
char z; int idx;
cin >> z >> idx;
if(z == '-')
{
if(!in[idx])
mx++;
else
tx--;
in[idx] = false;
}
else
{
tx++;
mx = max(mx, tx);
in[idx] = true;
}
}
cout << mx;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment