답안 #820973

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
820973 2023-08-11T06:45:31 Z alexander707070 Sightseeing in Kyoto (JOI22_kyoto) C++14
0 / 100
3 ms 340 KB
#include<bits/stdc++.h>
#define MAXN 100007
using namespace std;

const long long inf=1e17;

int n,m;
long long a[MAXN],b[MAXN];
long long dp[MAXN];

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=m;i++){
        cin>>b[i];
    }

    dp[1]=0;
    for(long long i=2;i<=max(n,m);i++){
        dp[i]=inf;
        for(long long f=i-1;f>=1;f--){
            dp[i]=min(dp[i],dp[f]+(i-f)*(a[i]+b[f]));
            dp[i]=min(dp[i],dp[f]+(i-f)*(a[f]+b[i]));
        }
    }
    
    cout<<dp[max(n,m)]<<"\n";


    return 0;   
}


 
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Incorrect 3 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -