제출 #821075

#제출 시각아이디문제언어결과실행 시간메모리
821075danikoynovSightseeing in Kyoto (JOI22_kyoto)C++14
10 / 100
8 ms8228 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const int maxn = 1e3 + 10; const ll inf = 1e18; int h, w; ll a[maxn], b[maxn], dp[maxn][maxn]; void solve() { 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; dp[i][j] = inf; if (i != 1) dp[i][j] = min(dp[i - 1][j] + b[j], dp[i][j]); if (j != 1) dp[i][j] = min(dp[i][j - 1] + a[i], dp[i][j]); } } cout << dp[h][w] << endl; } int main() { solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...