Submission #576898

# Submission time Handle Problem Language Result Execution time Memory
576898 2022-06-13T17:57:53 Z emad234 Exam (eJOI20_exam) C++17
0 / 100
1 ms 468 KB
#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++){
    dp[i] = dp[i - 1];
    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 time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 0 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 0 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 0 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -