# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
131487 | 2019-07-17T08:14:37 Z | Just_Solve_The_Problem | Pinball (JOI14_pinball) | C++11 | 15 ms | 16252 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const int maxn = (int)1e5 + 7; const int smalln = (int)1e3 + 7; int n, m; int a[maxn], b[maxn], c[maxn], d[maxn]; ll dp[2][smalln][smalln]; int pos[maxn]; main() { scanf("%d %d", &m, &n); iota(pos, pos + m, 0); for (int i = 0; i < m; i++) { scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]); } if (n >= smalln) return 0; if (n == 1) { puts("0"); return 0; } for (int i = 0; i < smalln; i++) { for (int j = 0; j < smalln; j++) { dp[0][i][j] = dp[1][i][j] = 1e18; } } // work for (int i = 0; i < m; i++) { dp[0][i][i] = dp[1][i][i] = d[i]; for (int l = 0; l < i; l++) { for (int r = 0; r < i; r++) { if (a[l] > b[r] || b[i] + 1 < a[l] || b[r] + 1 < a[i]) continue; if (a[i] <= c[l] && c[l] <= b[i]) { dp[0][i][r] = min(dp[0][i][r], dp[0][l][r] + d[i]); dp[1][l][i] = min(dp[1][l][i], dp[0][l][r] + d[i]); } if (a[i] <= c[r] && c[r] <= b[i]) { dp[0][i][r] = min(dp[0][i][r], dp[1][l][r] + d[i]); dp[1][l][i] = min(dp[1][l][i], dp[1][l][r] + d[i]); } } } } ll ans = 1e18; // find ans for (int i = 0; i < m; i++) { for (int j = 0; j < m; j++) { if (a[i] == 1 && b[j] == n) { ans = min(ans, min(dp[0][i][j], dp[1][i][j])); } } } if (ans == (ll)1e18) ans = -1; printf("%lld\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 16248 KB | Output is correct |
2 | Correct | 15 ms | 16248 KB | Output is correct |
3 | Correct | 15 ms | 16248 KB | Output is correct |
4 | Correct | 15 ms | 16248 KB | Output is correct |
5 | Correct | 15 ms | 16252 KB | Output is correct |
6 | Correct | 15 ms | 16248 KB | Output is correct |
7 | Correct | 15 ms | 16248 KB | Output is correct |
8 | Correct | 15 ms | 16252 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 16248 KB | Output is correct |
2 | Correct | 15 ms | 16248 KB | Output is correct |
3 | Correct | 15 ms | 16248 KB | Output is correct |
4 | Correct | 15 ms | 16248 KB | Output is correct |
5 | Correct | 15 ms | 16252 KB | Output is correct |
6 | Correct | 15 ms | 16248 KB | Output is correct |
7 | Correct | 15 ms | 16248 KB | Output is correct |
8 | Correct | 15 ms | 16252 KB | Output is correct |
9 | Incorrect | 2 ms | 376 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 16248 KB | Output is correct |
2 | Correct | 15 ms | 16248 KB | Output is correct |
3 | Correct | 15 ms | 16248 KB | Output is correct |
4 | Correct | 15 ms | 16248 KB | Output is correct |
5 | Correct | 15 ms | 16252 KB | Output is correct |
6 | Correct | 15 ms | 16248 KB | Output is correct |
7 | Correct | 15 ms | 16248 KB | Output is correct |
8 | Correct | 15 ms | 16252 KB | Output is correct |
9 | Incorrect | 2 ms | 376 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 16248 KB | Output is correct |
2 | Correct | 15 ms | 16248 KB | Output is correct |
3 | Correct | 15 ms | 16248 KB | Output is correct |
4 | Correct | 15 ms | 16248 KB | Output is correct |
5 | Correct | 15 ms | 16252 KB | Output is correct |
6 | Correct | 15 ms | 16248 KB | Output is correct |
7 | Correct | 15 ms | 16248 KB | Output is correct |
8 | Correct | 15 ms | 16252 KB | Output is correct |
9 | Incorrect | 2 ms | 376 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |