Submission #554963

# Submission time Handle Problem Language Result Execution time Memory
554963 2022-04-29T18:31:10 Z Itamar Exam (eJOI20_exam) C++14
0 / 100
6 ms 468 KB
#include <map>
#include <iostream>
using namespace std;
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#define ll long long
#define vi vector<int> 
#define vll vector<ll>
#define pi pair<int,int> 
#define pll pair<ll,ll>

const int siz = 1e5;
int a[siz];
int b[siz];

int solve(int i, int j) {
    int n = j - i + 1;
    vi dp(n + 1, 1e9 + 1);
    dp[0] = 0;
    int max = 0;
    for (int t = 0; t < n; t++) {
        int x = b[t + i];
        auto it = lower_bound(dp.begin(), dp.end(), x);
        *it = x;
        if (max < it - dp.begin()) {
            max = it - dp.begin();
        }
    }
    return max;
}
int main()
{
    int n;
    cin >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a[i] = x;
        s.insert(x);
    }
    
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        b[i] = x;
        if (b[i] < a[i] || s.find(x) == s.end())
            b[i] = 1e9 + 1;
    }
    int sum = 0;
    int last = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] < a[i - 1]) {
            sum += solve(last, i - 1);
            last = i;
        }
    }
    sum+=solve(last, n - 1);
    cout << sum;
}
# 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 1 ms 212 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 6 ms 468 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 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -