#include"sequence.h"
#include<vector>
using namespace std;
int n;
int tree1[500000];
int tree2[500000];
vector<int>arr[500000];
int sequence(int N,vector<int>A){
n=N;
for(int i=0;i<n;i++){
arr[A[i]-1].push_back(i);
tree1[i]=-1;
tree2[i]=-1;
}
int res=0;
for(int v=0;v<n;v++){
if(arr[v].empty())
continue;
for(int i:arr[v])
tree1[i]=1;
for(int i=0;i<n;i++){
int sum1=0,sum2=0,num=0;
for(int j=i;j<n;j++){
sum1+=tree1[j];
sum2+=tree2[j];
if(tree1[j]==1&&tree2[j]==-1)
num++;
if(sum1>=0&&sum2<=0)
res=max(res,num);
}
}
for(int i:arr[v])
tree2[i]=1;
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
15820 KB |
Output is correct |
2 |
Correct |
5 ms |
15708 KB |
Output is correct |
3 |
Correct |
4 ms |
15708 KB |
Output is correct |
4 |
Correct |
5 ms |
15704 KB |
Output is correct |
5 |
Correct |
4 ms |
15708 KB |
Output is correct |
6 |
Correct |
7 ms |
15708 KB |
Output is correct |
7 |
Correct |
4 ms |
15704 KB |
Output is correct |
8 |
Correct |
5 ms |
15784 KB |
Output is correct |
9 |
Correct |
4 ms |
15704 KB |
Output is correct |
10 |
Correct |
4 ms |
15708 KB |
Output is correct |
11 |
Correct |
5 ms |
15704 KB |
Output is correct |
12 |
Correct |
5 ms |
15708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
15820 KB |
Output is correct |
2 |
Correct |
5 ms |
15708 KB |
Output is correct |
3 |
Correct |
4 ms |
15708 KB |
Output is correct |
4 |
Correct |
5 ms |
15704 KB |
Output is correct |
5 |
Correct |
4 ms |
15708 KB |
Output is correct |
6 |
Correct |
7 ms |
15708 KB |
Output is correct |
7 |
Correct |
4 ms |
15704 KB |
Output is correct |
8 |
Correct |
5 ms |
15784 KB |
Output is correct |
9 |
Correct |
4 ms |
15704 KB |
Output is correct |
10 |
Correct |
4 ms |
15708 KB |
Output is correct |
11 |
Correct |
5 ms |
15704 KB |
Output is correct |
12 |
Correct |
5 ms |
15708 KB |
Output is correct |
13 |
Execution timed out |
2041 ms |
15704 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
15820 KB |
Output is correct |
2 |
Execution timed out |
2033 ms |
33012 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
15708 KB |
Output is correct |
2 |
Execution timed out |
2027 ms |
23804 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2037 ms |
38732 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
15820 KB |
Output is correct |
2 |
Correct |
5 ms |
15708 KB |
Output is correct |
3 |
Correct |
4 ms |
15708 KB |
Output is correct |
4 |
Correct |
5 ms |
15704 KB |
Output is correct |
5 |
Correct |
4 ms |
15708 KB |
Output is correct |
6 |
Correct |
7 ms |
15708 KB |
Output is correct |
7 |
Correct |
4 ms |
15704 KB |
Output is correct |
8 |
Correct |
5 ms |
15784 KB |
Output is correct |
9 |
Correct |
4 ms |
15704 KB |
Output is correct |
10 |
Correct |
4 ms |
15708 KB |
Output is correct |
11 |
Correct |
5 ms |
15704 KB |
Output is correct |
12 |
Correct |
5 ms |
15708 KB |
Output is correct |
13 |
Execution timed out |
2041 ms |
15704 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
15820 KB |
Output is correct |
2 |
Correct |
5 ms |
15708 KB |
Output is correct |
3 |
Correct |
4 ms |
15708 KB |
Output is correct |
4 |
Correct |
5 ms |
15704 KB |
Output is correct |
5 |
Correct |
4 ms |
15708 KB |
Output is correct |
6 |
Correct |
7 ms |
15708 KB |
Output is correct |
7 |
Correct |
4 ms |
15704 KB |
Output is correct |
8 |
Correct |
5 ms |
15784 KB |
Output is correct |
9 |
Correct |
4 ms |
15704 KB |
Output is correct |
10 |
Correct |
4 ms |
15708 KB |
Output is correct |
11 |
Correct |
5 ms |
15704 KB |
Output is correct |
12 |
Correct |
5 ms |
15708 KB |
Output is correct |
13 |
Execution timed out |
2041 ms |
15704 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |