# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
998839 | snpmrnhlol | Building 4 (JOI20_building4) | C++17 | 518 ms | 45328 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.
#include<bits/stdc++.h>
using namespace std;
const int N = 5e5;
const int inf = 2e9;
int v[2*N][2];
pair<int,int> dp[2*N][2];
bool ans[2*N];
int main(){
int n;
cin>>n;
for(int i = 0;i < 2*n;i++){
cin>>v[i][0];
}
for(int i = 0;i < 2*n;i++){
cin>>v[i][1];
}
for(int i = 2*n - 1;i >= 0;i--){
dp[i][0] = {inf,-inf};
dp[i][1] = {inf,-inf};
if(i == 2*n - 1){
dp[i][0] = {0,0};
dp[i][1] = {1,1};
}else{
for(int j = 0;j < 2;j++){
for(int k = 0;k < 2;k++){
if(v[i][j] <= v[i + 1][k]){
dp[i][j].first = min(dp[i][j].first,dp[i + 1][k].first + j);
dp[i][j].second = max(dp[i][j].second,dp[i + 1][k].second + j);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |