# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
947391 | weakweakweak | 건물 4 (JOI20_building4) | C++17 | 43 ms | 12952 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//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... |