#include <bits/stdc++.h>
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, q;
std::cin >> n >> q;
std::vector<int> a(q + 1);
for(int i = 1; i <= q; i++) {
std::cin >> a[i];
}
int ans = 0;
for(int i = 1; i < n; i++) {
std::map<int,int> was;
int c = 0;
for(int j = 1; j <= q; j++) {
//std::cout << i << " " << j << " " << was[i] << "\n";
if(a[j] == i) {
if(was[i]) {
c += 1;
}
was[i] = 1;
}
if(a[j] == - i) {
was[i] = 0;
}
}
ans = std::max(ans, c);
}
std::cout << ans;
}
# | 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... |