#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
ll n, q, x, ans = 0;
cin >> n >> q;
unordered_set <int> s;
while(q--)
{
cin >> x;
if (x < 0)
s.erase(-x);
else
{
if (s.find(x) != s.end()) {
++ans;
s.clear();
}
s.insert(x);
}
}
cout << ans << "\n";
return 0;
}
// V1C
# | 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... |