제출 #631949

#제출 시각아이디문제언어결과실행 시간메모리
631949S2speedSightseeing in Kyoto (JOI22_kyoto)C++17
10 / 100
5 ms8292 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize ("Ofast") #define all(x) x.begin() , x.end() typedef long long ll; typedef pair<ll , ll> pll; const ll maxn = 1e3 + 17 , inf = 2e16; ll a[maxn] , b[maxn] , dp[maxn][maxn]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n , m; cin>>n>>m; for(ll i = 0 ; i < n ; i++){ cin>>a[i]; } for(ll j = 0 ; j < m ; j++){ cin>>b[j]; } dp[0][0] = 0; for(ll i = 1 ; i < n ; i++){ dp[i][0] = b[0] * i; } for(ll j = 1 ; j < m ; j++){ dp[0][j] = a[0] * j; } for(ll i = 1 ; i < n ; i++){ for(ll j = 1 ; j < m ; j++){ dp[i][j] = min(dp[i - 1][j] + b[j] , dp[i][j - 1] + a[i]); } } cout<<dp[n - 1][m - 1]<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...