# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1111632 | onlk97 | 건물 4 (JOI20_building4) | C++14 | 199 ms | 45648 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
using namespace std;
using pii=pair <int,int>;
pii merge(pii a,pii b){
if (a.x==-1) return b;
if (b.x==-1) return a;
return {min(a.x,b.x),max(a.y,b.y)};
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n;
cin>>n;
int a[2][2*n+1];
for (int i=0; i<2; i++){
for (int j=1; j<=2*n; j++) cin>>a[i][j];
}
pii dp[2][2*n+1];
for (int i=0; i<2; i++){
for (int j=1; j<=2*n; j++) dp[i][j]={-1,-1};
}
dp[0][1]={0,0}; dp[1][1]={1,1};
for (int j=2; j<=2*n; j++){
for (int i=0; i<2; i++){
for (int k=0; k<2; k++){
if (a[k][j-1]<=a[i][j]){
if (dp[k][j-1].x!=-1) dp[i][j]=merge(dp[i][j],{dp[k][j-1].x+i,dp[k][j-1].y+i});
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |