Submission #695304

#TimeUsernameProblemLanguageResultExecution timeMemory
695304GusterGoose27Sightseeing in Kyoto (JOI22_kyoto)C++11
10 / 100
9 ms8168 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 1000; const ll inf = 1e18; ll grid[MAXN][MAXN]; int cost[MAXN][2]; int n, m; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for (int i = 0; i < n; i++) cin >> cost[i][0]; for (int i = 0; i < m; i++) cin >> cost[i][1]; grid[0][0] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (i+j == 0) continue; grid[i][j] = inf; if (i) grid[i][j] = min(grid[i][j], grid[i-1][j]+cost[j][1]); if (j) grid[i][j] = min(grid[i][j], grid[i][j-1]+cost[i][0]); } } cout << grid[n-1][m-1] << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...