# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
131525 | 2019-07-17T08:40:38 Z | Just_Solve_The_Problem | Pinball (JOI14_pinball) | C++11 | 2 ms | 504 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[smalln][smalln]; int pos[maxn]; ll go(int i1, int i2) { if (b[i2] == n) return 0; ll &res = dp[i1][i2]; if (res != (ll)1e18) return res; res = 1e18 - 1; for (int i = 0; i < m; i++) { if (i1 == i) continue; if (i < i1) { if (c[i] <= b[i2] && i < i2) { if (b[i] > b[i2]) { res = min(res, go(i1, i) + d[i]); } } } else { if (a[i] <= c[i1] && c[i1] <= b[i]) { if (b[i2] > b[i]) { res = min(res, go(i, i2) + d[i]); } else { res = min(res, go(i, i) + d[i]); } } } } return res; } 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; } // work for (int i = 0; i < m; i++) { for (int j = 0; j < m; j++) { dp[i][j] = 1e18; } } // find ans ll ans = 1e18; for (int i = 0; i < m; i++) if (a[i] == 1) ans = min(ans, go(i, i) + d[i]); if (ans == (ll)1e18) ans = -1; printf("%lld\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Incorrect | 2 ms | 376 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Incorrect | 2 ms | 376 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Incorrect | 2 ms | 376 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |