제출 #780899

#제출 시각아이디문제언어결과실행 시간메모리
780899eltu0815Sightseeing in Kyoto (JOI22_kyoto)C++14
10 / 100
8 ms8232 KiB
#include <bits/stdc++.h> #define MAX 500005 #define MOD (ll)(1e9+7) #define INF (ll)(1e18) #define inf (1987654321) using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; int n, m, q; int a[100005], b[100005]; ll dp[1005][1005]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for(int i = 1; i <= n; ++i) cin >> a[i]; for(int i = 1; i <= m; ++i) cin >> b[i]; for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) dp[i][j] = INF; dp[1][1] = 0; for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) { dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + a[i]); dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + b[j]); } cout << dp[n][m]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...