# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
131525 | Just_Solve_The_Problem | Pinball (JOI14_pinball) | C++11 | 2 ms | 504 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |