Submission #712917

#TimeUsernameProblemLanguageResultExecution timeMemory
712917lamSightseeing in Kyoto (JOI22_kyoto)C++14
10 / 100
9 ms8280 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e3 + 10;
typedef pair<int,int> ii;
#define ff first
#define ss second
int n,m;
int a[maxn],b[maxn];
int dp[maxn][maxn];
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cin>>n>>m;
    for (int i=1; i<=n; i++) cin>>a[i];
    for (int j=1; j<=m; j++) cin>>b[j];
    for (int i=0; i<=n; i++)
        for (int j=0; j<=m; j++) dp[i][j] = 1e18;
    dp[1][1] = 0;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
    {
        if (i==1&&j==1) continue;
        dp[i][j] = min(dp[i-1][j] + b[j], dp[i][j-1] + a[i]);
    }
    cout<<dp[n][m]<<'\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...