#include <bits/stdc++.h>
using namespace std;
int sequence(int n, vector<int> a) {
int ans = 0;
for (int i = 0; i < n; ++i) {
multiset<int> x;
for (int j = i; j < n; ++j) {
x.insert(a[j]);
int cnt = 0;
int d = (j - i) >> 1;
int b = (j - i + 1) >> 1;
int c1 = 0, c2 = 0;
for (auto k: x) {
if (cnt == d)
c1 = k;
if (cnt == b) {
c2 = k;
break;
}
++cnt;
}
int l = *x.upper_bound(c1) - *x.lower_bound(c1) + 1;
int r = *x.upper_bound(c2) - *x.lower_bound(c2) + 1;
if (l > ans)
ans = l;
if (r > ans)
ans = r;
// cout << x.count(c1) << endl;
// cout << x.count(c2) << endl;
}
}
return ans;
}
//int main() {
// int n;
// cin >> n;
// vector<int> a(n);
// for (int i = 0; i < n; ++i)
// cin >> a[i];
// cout << sequence(n, a);
// return 0;
//}
# |
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 |
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 |
348 KB |
Output is correct |
2 |
Execution timed out |
2092 ms |
6632 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
2058 ms |
6336 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2036 ms |
5716 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
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 |
- |