# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
994185 | 2024-06-07T08:28:06 Z | vjudge1 | Sightseeing in Kyoto (JOI22_kyoto) | C++17 | 456 ms | 1048576 KB |
#include <climits> #include <iostream> #include <vector> using namespace std; using ll = long long; struct s { ll pos, value; }; ll solve(vector<s> const& a, vector<s> const& b) { vector dp(a.size(), vector<ll>(b.size(), LLONG_MAX / 3)); dp[0][0] = 0; for (int i = 0; i < a.size(); i++) { for (int j = 0; j < b.size(); j++) { if (i < a.size() - 1) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + b[j].value * (a[i + 1].pos - a[i].pos)); if (j < b.size() - 1) dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + a[i].value * (b[j + 1].pos - b[j].pos)); } } return dp.back().back(); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); ll h, w; cin >> h >> w; vector<s> a(h); for (int i = 0; i < h; i++) { a[i].pos = i; cin >> a[i].value; } vector<s> b(w); for (int i = 0; i < w; i++) { b[i].pos = i; cin >> b[i].value; } cout << solve(a, b) << "\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 604 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 860 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 5 ms | 8380 KB | Output is correct |
10 | Correct | 5 ms | 8284 KB | Output is correct |
11 | Correct | 5 ms | 8284 KB | Output is correct |
12 | Correct | 6 ms | 8192 KB | Output is correct |
13 | Correct | 6 ms | 8284 KB | Output is correct |
14 | Correct | 6 ms | 8384 KB | Output is correct |
15 | Correct | 6 ms | 8284 KB | Output is correct |
16 | Correct | 6 ms | 8284 KB | Output is correct |
17 | Correct | 6 ms | 8284 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 352 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 0 ms | 456 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 3 ms | 3420 KB | Output is correct |
4 | Runtime error | 456 ms | 1048576 KB | Execution killed with signal 9 |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 604 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 860 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 5 ms | 8380 KB | Output is correct |
10 | Correct | 5 ms | 8284 KB | Output is correct |
11 | Correct | 5 ms | 8284 KB | Output is correct |
12 | Correct | 6 ms | 8192 KB | Output is correct |
13 | Correct | 6 ms | 8284 KB | Output is correct |
14 | Correct | 6 ms | 8384 KB | Output is correct |
15 | Correct | 6 ms | 8284 KB | Output is correct |
16 | Correct | 6 ms | 8284 KB | Output is correct |
17 | Correct | 6 ms | 8284 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 352 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 0 ms | 456 KB | Output is correct |
29 | Correct | 0 ms | 344 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 3 ms | 3420 KB | Output is correct |
32 | Runtime error | 456 ms | 1048576 KB | Execution killed with signal 9 |
33 | Halted | 0 ms | 0 KB | - |