Submission #839799

# Submission time Handle Problem Language Result Execution time Memory
839799 2023-08-30T16:28:09 Z tshabanov7 Exam (eJOI20_exam) C++17
12 / 100
16 ms 1108 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    if (count(b.begin(), b.end(), b[0]) == n) {
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] > b[0]) {
                continue;
            }

            bool ok = false;
            int j = i;
            while (j < n && a[j] <= b[0]) {
                ok |= a[j] == b[0];
                j++;
            }

            if (ok) {
                ans += j - i;
            }
            i = j - 1;
        }

        cout << ans << '\n';
        return 0;
    }

    if (is_sorted(a.begin(), a.end())) {
        vector<int> dp(n + 1);
        for (int i = 0; i < n; i++) {
            int cnt = 0;
            for (int j = i; j >= 0; j--) {
                cnt += b[j] == a[i];
                dp[i + 1] = max(dp[i + 1], dp[j] + cnt);
            }
        }

        cout << dp[n] << '\n';
        return 0;
    }

    return 0;
}
# 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 Correct 1 ms 212 KB Output is correct
2 Correct 4 ms 468 KB Output is correct
3 Correct 10 ms 980 KB Output is correct
4 Correct 12 ms 1108 KB Output is correct
5 Correct 16 ms 1108 KB Output is correct
6 Correct 8 ms 1108 KB Output is correct
7 Correct 9 ms 1108 KB Output is correct
8 Correct 16 ms 1108 KB Output is correct
# 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 340 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 -