Submission #631927

#TimeUsernameProblemLanguageResultExecution timeMemory
631927MahdiSightseeing in Kyoto (JOI22_kyoto)C++17
10 / 100
8 ms8216 KiB
#include<bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; #define all(v) v.begin(), v.end() #define F first #define S second typedef pair<int, int> pii; typedef long long ll; const int N=1e3+5; int n, m, a[N], b[N]; ll dp[N][N]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>m; if(n>1000) return 0; for(int i=0;i<n;++i){ cin>>a[i]; } for(int i=0;i<m;++i){ cin>>b[i]; } for(int i=0;i<n;++i) fill(dp[i], dp[i]+m, 1e18); dp[0][0]=0; for(int i=0;i<n;++i){ for(int j=0;j<m;++j){ if(i>0) dp[i][j]=dp[i-1][j]+b[j]; if(j>0) dp[i][j]=min(dp[i][j], dp[i][j-1]+a[i]); } } cout<<dp[n-1][m-1]<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...