# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
947391 | weakweakweak | Building 4 (JOI20_building4) | C++17 | 43 ms | 12952 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.
//joisc怎麼也有水題阿
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fs first
#define sc second
int n, a[510000], b[510000];
pii dp[510000][2];
pii dead = {1000000, -1000000};
int main () {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
for (int i = 1; i <= n * 2; i++) cin >> a[i];
for (int i = 1; i <= n * 2; i++) cin >> b[i];
a[0] = b[0] = -1, dp[0][0] = dp[0][1] = {0, 0};
for (int i = 1; i <= n * 2; i++) dp[i][0] = dp[i][1] = dead;
for (int i = 1; i <= n * 2; i++) {
{
bool y0 = (a[i] >= a[i - 1]) and (dp[i - 1][0] != dead), y1 = (a[i] >= b[i-1]) and (dp[i - 1][1] != dead);
if (y0 and y1) {
dp[i][0] . fs = min(dp[i - 1][0].fs, dp[i - 1][1].fs) + 1;
dp[i][0] . sc = max(dp[i - 1][0].sc, dp[i - 1][1].sc) + 1;
}
else if (y0) dp[i][0] = {dp[i - 1][0].fs + 1, dp[i - 1][0].sc + 1};
else if (y1) dp[i][0] = {dp[i - 1][1].fs + 1, dp[i - 1][1].sc + 1};
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |