이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ss second
#define pb push_back
#define mod 1000000007
#define N 200005
#define INF 1000000000000000005
#define pu push
#define ff first
#define pint pair<int,int>
typedef long long ll;
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
int t;
cin>>t;
bool take[n];
int cnt[n],ans=0;
set<int> st;
memset(cnt,0,sizeof(cnt));
memset(take,false,sizeof(take));
while(t--)
{
int a;
cin>>a;
if(a>0)
{
if(st.count(a)){
st.clear();
st.insert(a);
ans++;
}
else
st.insert(a);
}
else if(st.count(-a))
st.erase(-a);
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |