#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';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
7 ms |
852 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
12 ms |
3164 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
8 ms |
600 KB |
Output is correct |
8 |
Correct |
8 ms |
856 KB |
Output is correct |
9 |
Correct |
8 ms |
728 KB |
Output is correct |
10 |
Correct |
11 ms |
988 KB |
Output is correct |
11 |
Correct |
9 ms |
1116 KB |
Output is correct |
12 |
Correct |
10 ms |
1240 KB |
Output is correct |
13 |
Correct |
11 ms |
1880 KB |
Output is correct |
14 |
Correct |
15 ms |
3164 KB |
Output is correct |
15 |
Correct |
13 ms |
3164 KB |
Output is correct |
16 |
Correct |
14 ms |
3032 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
12 ms |
3160 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
16 ms |
3112 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
- |