Submission #576905

#TimeUsernameProblemLanguageResultExecution timeMemory
576905emad234Exam (eJOI20_exam)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> #define all(v) ((v).begin(),(v).end()) typedef long long ll; using namespace std; const int mod = 1e9 + 7; const int mxN = 2e6 + 1; int a[mxN]; int b[mxN]; int dp[mxN]; int main() { ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n; cin >>n; for(int i =0;i < n;i++){ cin >>a[i]; } for(int i = 0;i < n;i++){ cin >>b[i]; } for(int i = 0;i < n;i++){ if(i != 0) dp[i] = dp[i - 1]; if(i == 0){ if(a[i] == b[i]) dp[i] = 1; } else if(a[i] <= b[i]){ for(int j = i;j >= 0;j--){ if(a[j] == b[i]){ dp[i] = max(dp[i - 1],dp[j] + 1); } if(a[j] > a[i]) break; } for(int j = i;j < n;j++){ if(a[j] == b[i]){ dp[i] = max(dp[i],dp[i - 1] + 1); } if(a[j] > a[i]) break; } } } cout <<dp[n - 1]; } // nice
#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...