#include<bits/stdc++.h>
#include "sequence.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int sequence(int n,vector<int>A){
int ans=1;
int cnt[n+1];
for(int i=0;i<n;i++){
fill(cnt,cnt+n+1,0);
multiset<int,greater<int>>l;
multiset<int>r;
for(int j=i;j<n;j++){
cnt[A[j]]++;
if(l.size()==r.size()){
if(l.size()==0||A[j]>=*r.begin()){
r.insert(A[j]);
}
else{
int x=*l.begin();
r.insert(x);
l.erase(l.find(x));
l.insert(A[j]);
}
if(i!=j){
ans=max(ans,cnt[*r.begin()]);
}
}
else{
if(A[j]<=*r.begin()){
l.insert(A[j]);
}
else{
int x=*r.begin();
l.insert(x);
r.erase(r.find(x));
r.insert(A[j]);
}
ans=max({ans,cnt[*l.begin()],cnt[*r.begin()]});
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
436 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 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 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
436 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
241 ms |
520 KB |
Output is correct |
14 |
Correct |
240 ms |
548 KB |
Output is correct |
15 |
Correct |
247 ms |
524 KB |
Output is correct |
16 |
Correct |
244 ms |
344 KB |
Output is correct |
17 |
Correct |
241 ms |
524 KB |
Output is correct |
18 |
Correct |
175 ms |
348 KB |
Output is correct |
19 |
Correct |
245 ms |
344 KB |
Output is correct |
20 |
Correct |
237 ms |
348 KB |
Output is correct |
21 |
Correct |
244 ms |
532 KB |
Output is correct |
22 |
Correct |
259 ms |
532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Execution timed out |
2096 ms |
29676 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
2065 ms |
29704 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2027 ms |
29684 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
436 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
241 ms |
520 KB |
Output is correct |
14 |
Correct |
240 ms |
548 KB |
Output is correct |
15 |
Correct |
247 ms |
524 KB |
Output is correct |
16 |
Correct |
244 ms |
344 KB |
Output is correct |
17 |
Correct |
241 ms |
524 KB |
Output is correct |
18 |
Correct |
175 ms |
348 KB |
Output is correct |
19 |
Correct |
245 ms |
344 KB |
Output is correct |
20 |
Correct |
237 ms |
348 KB |
Output is correct |
21 |
Correct |
244 ms |
532 KB |
Output is correct |
22 |
Correct |
259 ms |
532 KB |
Output is correct |
23 |
Execution timed out |
2016 ms |
5464 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
436 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
241 ms |
520 KB |
Output is correct |
14 |
Correct |
240 ms |
548 KB |
Output is correct |
15 |
Correct |
247 ms |
524 KB |
Output is correct |
16 |
Correct |
244 ms |
344 KB |
Output is correct |
17 |
Correct |
241 ms |
524 KB |
Output is correct |
18 |
Correct |
175 ms |
348 KB |
Output is correct |
19 |
Correct |
245 ms |
344 KB |
Output is correct |
20 |
Correct |
237 ms |
348 KB |
Output is correct |
21 |
Correct |
244 ms |
532 KB |
Output is correct |
22 |
Correct |
259 ms |
532 KB |
Output is correct |
23 |
Execution timed out |
2096 ms |
29676 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |