# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
955744 | 2024-03-31T11:42:49 Z | vjudge1 | Pinball (JOI14_pinball) | C++17 | 1000 ms | 8448 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll m, n, i, j, k, a, b, w = 0, ma, r = (1LL << 50); cin >> m >> n; vector<vector<ll> > v, vv(m); vector<ll> lp, rp; vector<ll> d(m), s(3 * m); for (i = 0; i < m; i++) { cin >> j; v.push_back({j - 1, i, -1}); cin >> j; v.push_back({j - 1, i, 1}); cin >> j; v.push_back({j - 1, i, 0}); cin >> d[i]; } sort(v.begin(), v.end()); if (v[0][0] || v[3 * m - 1][0] != n - 1) { cout << -1; return 0; } for (i = 0; i < 3 * m; i++) { if (!i) s[i] = 0; else if (v[i][0] > v[i - 1][0]) s[i] = s[i - 1] + 1; else s[i] = s[i - 1]; w = max(w, s[i]); } for (i = 0; i < 3 * m; i++) v[i] = {v[i][1], s[i], v[i][2]}; sort(v.begin(), v.end()); for (i = 0; i < m; i++) vv[i] = {v[3 * i][1], v[3 * i + 1][1], v[3 * i + 2][1]}; lp.resize(w + 1); rp.resize(w + 1); for (i = 0; i <= w; i++) lp[i] = rp[i] = r; lp[0] = rp[w] = 0; ma = r; ll ml, mr; for (i = 0; i < m; i++) { for (j = vv[i][0]; j < vv[i][1]; j++) lp[vv[i][1]] = min(lp[vv[i][1]], lp[j] + d[i]); for (j = vv[i][2]; j > vv[i][1]; j--) rp[vv[i][1]] = min(rp[vv[i][1]], rp[j] + d[i]); ll ml, mr; ml = lp[vv[i][0]]; for (j = w; j > vv[i][0]; j--) ml = min(ml, lp[j]); mr = rp[vv[i][2]]; for (j = 0; j < vv[i][2]; j++) mr = min(mr, rp[j]); ma = min(ma, ml + mr + d[i]); } for (j = 1; j <= w; j++) rp[j] = min(rp[j], rp[j - 1]); for (j = w - 1; j >= 0; j--) lp[j] = min(lp[j], lp[j + 1]); for (j = 0; j <= w; j++) ma = min(ma, lp[j] + rp[j]); if (ma < r) cout << ma; else cout << -1; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 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 | 1 ms | 344 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 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 | 1 ms | 344 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 5 ms | 604 KB | Output is correct |
18 | Correct | 2 ms | 600 KB | Output is correct |
19 | Correct | 2 ms | 604 KB | Output is correct |
20 | Correct | 5 ms | 740 KB | Output is correct |
21 | Correct | 2 ms | 604 KB | Output is correct |
22 | Correct | 5 ms | 604 KB | Output is correct |
23 | Correct | 5 ms | 604 KB | Output is correct |
24 | Correct | 5 ms | 776 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 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 | 1 ms | 344 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 5 ms | 604 KB | Output is correct |
18 | Correct | 2 ms | 600 KB | Output is correct |
19 | Correct | 2 ms | 604 KB | Output is correct |
20 | Correct | 5 ms | 740 KB | Output is correct |
21 | Correct | 2 ms | 604 KB | Output is correct |
22 | Correct | 5 ms | 604 KB | Output is correct |
23 | Correct | 5 ms | 604 KB | Output is correct |
24 | Correct | 5 ms | 776 KB | Output is correct |
25 | Correct | 424 ms | 3492 KB | Output is correct |
26 | Execution timed out | 1014 ms | 8448 KB | Time limit exceeded |
27 | Halted | 0 ms | 0 KB | - |