# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
440761 |
2021-07-02T23:27:58 Z |
MrDeboo |
Exam (eJOI20_exam) |
C++17 |
|
1000 ms |
1740 KB |
#include <bits/stdc++.h>
#define int long long
#define mod 1000000007
#define endl '\n'
using namespace std;
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin>>n;
pair<int,int>pr[n];
for(int i=0;i<n;i++){
cin>>pr[i].first;
}
for(int i=0;i<n;i++){
cin>>pr[i].second;
}
bool bl[n];
memset(bl,false,sizeof(bl));
for(int i=0;i<n;i++){
int a=0,b=0,z=i,maxi=0,x=0,y=0;
for(int w=i;w<n&&pr[w].first<=pr[i].first;w++){
if(pr[w].second==pr[i].first)a++;
if(bl[w])b++;
if(a-b>=maxi){x=a;y=b;maxi=a-b;z=w;}
}
int f=i;
a=x;b=y;
for(int w=(z==i?i:i-1);w>=0&&pr[w].first<=pr[i].first;w--){
if(a-b>=maxi){maxi=a-b;f=i;}
if(pr[w].second==pr[i].first)a++;
if(bl[w])b++;
if(a-b>=maxi){maxi=a-b;f=w;}
}
if(maxi>0){
for(int w=f;w<=z;w++){
if(pr[w].second==pr[i].first)bl[w]=true;
else bl[w]=false;
}
}
}
int ans=0;
for(int i=0;i<n;i++)if(bl[i])ans++;
cout<<ans;
}
//5 1 1 1 6 5
//5 5 6 5 6
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
73 ms |
632 KB |
Output is correct |
3 |
Execution timed out |
1083 ms |
1740 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Incorrect |
12 ms |
972 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |