Submission #699276

# Submission time Handle Problem Language Result Execution time Memory
699276 2023-02-16T11:40:54 Z mmmmaasss Exam (eJOI20_exam) C++14
0 / 100
398 ms 392448 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main()
{
   int n;cin >> n;
   int rr = 0;
    vector<int> a(n + 1) , b(n + 1);
    for(int i = 1;i <= n;i ++){
        cin >> a[i];
    }
    for(int i = 1;i <= n;i ++){
        cin >> b[i];
    }
    vector<vector<ll>> dp(n + 1 , vector<ll>(n + 1)) , p(n + 1 , vector<ll>(n + 1));
    for(int i = 1;i <= n;i ++){
        int c = a[i] == b[i];
        dp[i][i] = c;
        for(int j = i - 1;j >= 1;j --){
            c += a[i] == b[j];
            p[j][i] = c;
        }
    }
    for(int i = 1;i <= n;i ++){
        for(int j = i - 1;j >= 1;j --){
            dp[1][i] = max(p[j][i] + dp[1][j],dp[1][i]);
        }
    }
    cout << dp[1][n] << endl;
}

Compilation message

exam.cpp: In function 'int main()':
exam.cpp:10:8: warning: unused variable 'rr' [-Wunused-variable]
   10 |    int rr = 0;
      |        ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 15956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 398 ms 392448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -