Submission #466865

# Submission time Handle Problem Language Result Execution time Memory
466865 2021-08-20T21:31:00 Z TlenekWodoru Exam (eJOI20_exam) C++14
27 / 100
99 ms 588 KB
#include <bits/stdc++.h>
using namespace std;
int A[100009];
int B[100009];
pair<int,int>granica[100009];
int dp[2][100009];
map<int,int>miejsce;
int main()
{ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>A[i];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>B[i];
    }
    map<int,int>M;
    M[2000000000]=0;
    for(int i=1;i<=n;i++)
    {
        granica[i].first=M.upper_bound(A[i])->second+1;
        M[A[i]]=i;
    }
    M.clear();
    M[2000000000]=n+1;
    for(int i=n;i>=1;i--)
    {
        granica[i].second=M.upper_bound(A[i])->second-1;
        M[A[i]]=i;
    }
    M.clear();
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(A[i]==B[j]&&granica[i].first<=j&&j<=granica[i].second)
            {
                dp[i%2][j]=dp[i%2][j-1]+1;
            }
            else
            {
                dp[i%2][j]=max(dp[i%2][j-1],dp[(i-1)%2][j]);
            }
        }
    }
    cout<<dp[n%2][n]<<endl;
    return 0;
}





# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 17 ms 476 KB Output is correct
4 Correct 89 ms 588 KB Output is correct
5 Correct 98 ms 588 KB Output is correct
6 Correct 97 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 99 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Incorrect 1 ms 332 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 17 ms 476 KB Output is correct
10 Correct 89 ms 588 KB Output is correct
11 Correct 98 ms 588 KB Output is correct
12 Correct 97 ms 588 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Incorrect 1 ms 332 KB Output isn't correct
16 Halted 0 ms 0 KB -