Submission #554815

#TimeUsernameProblemLanguageResultExecution timeMemory
554815DanShadersSightseeing in Kyoto (JOI22_kyoto)C++17
10 / 100
11 ms8340 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; namespace x = __gnu_pbds; template <typename T> using ordered_set = x::tree<T, x::null_type, less<T>, x::rb_tree_tag, x::tree_order_statistics_node_update>; template <typename T> using normal_queue = priority_queue<T, vector<T>, greater<>>; #define all(x) begin(x), end(x) #define sz(x) ((int) (x).size()) #define x first #define y second using ll = long long; using ld = long double; #define int ll const int N = 1010, INF = 0x3f3f3f3f3f3f3f3f; int a[N], b[N]; int dp[N][N]; signed main() { cin.tie(0)->sync_with_stdio(0); int n, m; cin >> n >> m; for (int i = 0; i < n; ++i) { cin >> a[i]; } for (int i = 0; i < m; ++i) { cin >> b[i]; } fill(dp[0], dp[N], +INF); dp[0][0] = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + b[j]); dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + a[i]); } } cout << dp[n - 1][m - 1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...