| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 131382 | Just_Solve_The_Problem | Pinball (JOI14_pinball) | C++11 | 8 ms | 8312 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];
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;
for (int i = 0; i < smalln; i++) {
for (int j = 0; j < smalln; j++) {
dp[i][j] = 1e18;
}
}
sort(pos, pos + m, [&](const int &A, const int &B) {
return a[A] < a[B];
});
for (int i = 0; i < m; i++) {
if (a[pos[i]] == 1) dp[i][i] = d[pos[i]];
}
if (a[pos[0]] != 1) {
puts("-1");
return 0;
}
for (int i = 0; i < m; i++) {
for (int j = 0; j <= i; j++) {
for (int k = i + 1; k < m; k++) {
if (pos[i] < pos[k]) {
if (c[pos[i]] >= a[pos[k]] && c[pos[i]] <= b[pos[k]]) {
if (b[pos[j]] >= b[pos[k]]) {
dp[k][j] = min(dp[k][j], dp[i][j] + d[pos[k]]);
} else {
dp[k][k] = min(dp[k][k], dp[i][j] + d[pos[k]]);
}
}
} else {
if (c[pos[k]] >= a[pos[i]] && c[pos[k]] <= b[pos[i]]) {
if (b[pos[j]] < b[pos[k]]) {
dp[i][k] = min(dp[i][k], dp[i][j] + d[pos[k]]);
}
}
}
}
}
}
ll ans = 1e18;
for (int i = 0; i < m; i++) {
if (b[pos[i]] == n) {
for (int j = 0; j < m; j++) {
ans = min(ans, dp[j][i]);
}
}
}
if (ans == (ll)1e18) ans = -1;
printf("%lld", 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... | ||||
