#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<int,int>, null_type,less<>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
int32_t sequence(int32_t N, std::vector<int32_t> A) {
int32_t ans = 0;
auto calc = [&](int len,int curr){
vector<int32_t> cnt(4);
if(len>N)return false;
for(int i=0;i<len-1;i++)cnt[A[i]]++;
bool works = false;
for(int i=len-1;i<N;i++){
cnt[A[i]]++;
if(i-len>=0)cnt[A[i-len]]--;
int lower,upper;
if(curr==1){
lower = 0;
upper = cnt[1]-1;
} else if(curr==2){
lower = cnt[1];
upper = cnt[2]+cnt[1]-1;
} else {
lower = cnt[2]+cnt[1];
upper = len-1;
}
if(len/2<=upper and lower<=len/2){
ans = max(ans,cnt[curr]);
works = true;
}
if(len%2==0 and (len/2)-1 <= upper and (len/2)-1 >= lower){
ans = max(ans,cnt[curr]);
works = true;
}
}
return works;
};
for(int i=1;i<=3;i++){
int curr = 0;
for(int jump=262144;jump;jump/=2)if(calc(curr+jump,i))curr+=jump;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
60 ms |
8528 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
113 ms |
4344 KB |
Output is correct |
3 |
Correct |
88 ms |
4188 KB |
Output is correct |
4 |
Correct |
86 ms |
5332 KB |
Output is correct |
5 |
Correct |
96 ms |
5192 KB |
Output is correct |
6 |
Correct |
74 ms |
5324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
46 ms |
8280 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |