Submission #560854

#TimeUsernameProblemLanguageResultExecution timeMemory
5608548e7Sightseeing in Kyoto (JOI22_kyoto)C++17
10 / 100
11 ms8232 KiB
//Challenge: Accepted #include <bits/stdc++.h> using namespace std; #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r) { while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif #define ll long long #define maxn 1005 #define pii pair<int, int> #define ff first #define ss second #define io ios_base::sync_with_stdio(0);cin.tie(0); const ll inf = 1LL<<60; ll dp[maxn][maxn], a[maxn], b[maxn]; int main() { io 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]; for (int i = 0;i < n;i++) { for (int j = 0;j < m;j++) dp[i][j] = inf; } dp[0][0] = 0; for (int i = 0;i < n;i++) { for (int j = 0;j < m;j++) { if (i == 0 && j == 0) continue; if (i) dp[i][j] = min(dp[i][j], dp[i-1][j] + b[j]); if (j) dp[i][j] = min(dp[i][j], dp[i][j-1] + a[i]); } } cout << dp[n-1][m-1] << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...