Submission #1049476

#TimeUsernameProblemLanguageResultExecution timeMemory
1049476marExam (eJOI20_exam)C++14
27 / 100
14 ms860 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 100008; ll dp[maxn]; int main() { int n; cin>>n; int ans=0; vector<int> a, b; bool flag = true; int inp; for(int i=0;i<n;i++) { cin>>inp; a.push_back(inp); } for(int i=0;i<n;i++){ cin>>inp; b.push_back(inp); } vector<int> v; map<int, int> idx; for(int i=0; i<n; i++) idx[a[i]] = i; for(int i=0; i<n; i++) { if(idx.count(b[i]) && i <= idx[b[i]]) v.push_back(b[i]); } ll mx = 0; ll sz = v.size(); for (int i=0; i<sz; i++) { for(int j=0; j<i; j++) { if(v[i] >= v[j]) { dp[i] = max(dp[i], dp[j]+1); } } } for(int i=0; i<sz; i++) { mx = max(mx,dp[i]); } cout<<mx+1<<endl; return 0; }

Compilation message (stderr)

exam.cpp: In function 'int main()':
exam.cpp:10:9: warning: unused variable 'ans' [-Wunused-variable]
   10 |     int ans=0;
      |         ^~~
exam.cpp:12:7: warning: unused variable 'flag' [-Wunused-variable]
   12 |  bool flag = true;
      |       ^~~~
#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...