#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define mod 1000000007
#define sp << " " <<
#define endl << '\n'
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int N, Q;
cin >> N >> Q;
vector<int> part2(N);
int ret = 0;
int s = 1;
for (int i = 0; i < Q; i++){
long long int K;
cin >> K;
if (K < 0){
part2[-K] = 0;
}else{
if (part2[K] == s){
ret++;
s++;
part2[K] = s;
}else
part2[K] = s;
}
}
cout << ret;
}
# | 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... |