#include <bits/stdc++.h>
using namespace std;
#define int long long
int v[200005];
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int m, n; cin >> m >> n;
int mx = 0;
while(n--){
int x; cin >> x;
if(x){
if(v[x] == mx) v[x] = ++mx;
else v[x] = mx;
}else if(v[-x] != 0) v[-x]--;
}
cout << max(mx - 1ll, 0ll) << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
7 ms |
832 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
12 ms |
3164 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
7 ms |
860 KB |
Output is correct |
8 |
Correct |
7 ms |
832 KB |
Output is correct |
9 |
Correct |
8 ms |
600 KB |
Output is correct |
10 |
Correct |
9 ms |
856 KB |
Output is correct |
11 |
Correct |
10 ms |
1116 KB |
Output is correct |
12 |
Correct |
10 ms |
1372 KB |
Output is correct |
13 |
Correct |
11 ms |
1988 KB |
Output is correct |
14 |
Correct |
13 ms |
3164 KB |
Output is correct |
15 |
Correct |
14 ms |
3156 KB |
Output is correct |
16 |
Correct |
19 ms |
3416 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
12 ms |
3164 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
13 ms |
3096 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |