Submission #833478

#TimeUsernameProblemLanguageResultExecution timeMemory
833478vjudge1Exam (eJOI20_exam)C++17
0 / 100
1091 ms596 KiB
#include<bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long int n; int a[100005], b[100005]; int count(int l, int r){ int mx = -1; for(int i=l; i<=r; i++) mx = max(mx, a[i]); int cnt = 0; for(int i=l; i<=r; i++){ if(mx == b[i]) cnt++; } return cnt; } int f(int now){ if(now > n) return 0; int ret = 0; for(int i=now; i<=n; i++){ ret = max(ret, count(now, i)+f(i+1)); } return ret; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cin>>n; for(int i=1; i<=n; i++) cin>>a[i]; for(int i=1; i<=n; i++) cin>>b[i]; cout<<f(1)<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...