Submission #1321729

#TimeUsernameProblemLanguageResultExecution timeMemory
1321729anteknneSightseeing in Kyoto (JOI22_kyoto)C++20
10 / 100
6 ms8404 KiB
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; #define pb push_back #define pii pair<int, int> #define pll pair<ll, ll> #define st first #define nd second #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> #define debug false const int MAXH = 1000 + 17; const ll INF = ll(1000 * 1000 * 1000) * ll(1000 * 1000 * 1000); ll a[MAXH][2]; ll dp[MAXH][MAXH]; int main () { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int h, w; cin >> h >> w; for (int i = 0; i < h; i ++) { cin >> a[i][0]; } for (int i = 0; i < w; i ++) { cin >> a[i][1]; } for (int i = 0; i < h; i ++) { for (int j = 0; j < w; j ++) { dp[i][j] = INF; } } dp[h - 1][w - 1] = 0; for (int i = h - 1; i >= 0; i --) { for (int j = w - 1; j >= 0; j --) { if (i + 1 < h) { dp[i][j] = min(dp[i][j], dp[i + 1][j] + a[j][1]); } if (j + 1 < w) { dp[i][j] = min(dp[i][j], dp[i][j + 1] + a[i][0]); } } } cout << dp[0][0] << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...