# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
117610 | evpipis | Pinball (JOI14_pinball) | C++17 | 1077 ms | 2156 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int len = 1e5+5;
const ll inf = 1e18;
int lef[len], rig[len], pos[len], cost[len];
ll dp[len][3];
int main(){
int n, m;
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; i++)
scanf("%d %d %d %d", &lef[i], &rig[i], &pos[i], &cost[i]);
ll ans = inf;
for (int i = 1; i <= n; i++){
ll d0 = inf, d1 = inf, d2 = inf;
if (lef[i] == 1 && rig[i] == m)
d0 = d1 = d2 = cost[i];
else if (lef[i] == 1)
d0 = cost[i];
else if (rig[i] == m)
d1 = cost[i];
for (int j = 1; j < i; j++){
if (pos[j] < lef[i] || rig[i] < pos[j])
continue;
d0 = min(d0, cost[i]+dp[j][0]);
d1 = min(d1, cost[i]+dp[j][1]);
}
d2 = min(d2, d0+d1-cost[i]);
dp[i][0] = d0;
dp[i][1] = d1;
dp[i][2] = d2;
ans = min(ans, d2);
//printf("i = %d, d0 = %lld, d1 = %lld, d2 = %lld\n", i, d0, d1, d2);
}
if (ans == inf)
printf("-1\n");
else
printf("%lld", ans);
return 0;
}
컴파일 시 표준 에러 (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... |