# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1000667 | 42kangaroo | Building 4 (JOI20_building4) | C++17 | 194 ms | 47236 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//
// Created by 42kangaroo on 18/06/2024.
//
#include "bits/stdc++.h"
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
array<vector<int>, 2> a;
a.fill(vector<int>(2 * n));
array<vector<pair<int, int>>, 2> dp;
dp.fill(vector<pair<int, int>>(2 * n, {1e9, 0}));
for (int i = 0; i < 2 * n; ++i) {
cin >> a[0][i];
}
for (int i = 0; i < 2 * n; ++i) {
cin >> a[1][i];
}
dp[0][0] = {0, 0};
dp[1][0] = {1, 1};
for (int i = 1; i < 2 * n; ++i) {
for (int j = 0; j < 2; ++j) {
for (int k = 0; k < 2; ++k) {
if (a[j][i - 1] <= a[k][i]) {
dp[k][i] = {min(dp[k][i].first, dp[j][i - 1].first + k),
max(dp[k][i].second, dp[j][i - 1].second + k)};
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |