| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 103048 | luciocf | Pinball (JOI14_pinball) | C++14 | 8 ms | 640 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3+10;
const long long inf = 2e18+10;
typedef long long ll;
int l[maxn], r[maxn], p[maxn], d[maxn];
ll dp[2][maxn];
int main(void)
{
int n, m;
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; i++)
{
scanf("%d %d %d %d", &l[i], &r[i], &p[i], &d[i]);
dp[0][i] = dp[1][i] = inf;
}
for (int i = 1; i <= n; i++)
{
if (l[i] == 1) dp[0][i] = d[i];
for (int j = i-1; j >= 1; j--)
if (p[j] >= l[i] && p[j] <= r[i])
dp[0][i] = min(dp[0][i], 1ll*d[i]+dp[0][j]);
}
for (int i = 1; i <= n; i++)
{
if (r[i] == m) dp[1][i] = d[i];
for (int j = i-1; j >= 1; j--)
if (p[j] >= l[i] && p[j] <= r[i])
dp[1][i] = min(dp[1][i], 1ll*d[i]+dp[1][j]);
}
ll ans = inf;
for (int i = 1; i <= n; i++)
if (dp[0][i] != inf && dp[1][i] != inf)
ans = min(ans, dp[0][i]+dp[1][i]-1ll*d[i]);
if (ans == inf) printf("-1\n");
else 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... | ||||
