Submission #642459

#TimeUsernameProblemLanguageResultExecution timeMemory
642459kdn5549Sightseeing in Kyoto (JOI22_kyoto)C++17
10 / 100
9 ms8232 KiB
#include<bits/stdc++.h> #define fi first #define se second #define eb emplace_back #define ep emplace #define all(x) (x).begin(),(x).end() using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef pair<ll,ll> pl; const ll INF=1e18; const ll mod=1e9+7; const ll mxn=1005; int h,w,a[mxn],b[mxn]; ll dp[mxn][mxn]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin>>h>>w; for (int i=1;i<=h;i++) cin>>a[i]; for (int i=1;i<=w;i++) cin>>b[i]; for (int i=1;i<=h;i++) for(int j=1;j<=w;j++) { if(i==1 && j==1) continue; ll x=(i>1?dp[i-1][j]+b[j]:INF); ll y=(j>1?dp[i][j-1]+a[i]:INF); dp[i][j]=min(x,y); } cout<<dp[h][w]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...