# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
754959 | MilosMilutinovic | Treatment Project (JOI20_treatment) | C++14 | 3040 ms | 3020 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 10;
const ll inf = 0x3f3f3f3f3f3f3f3f;
int n, m, t[N], l[N], r[N], c[N], order[N];
ll dp[N];
bool cmp(int i, int j) { return l[i] < l[j]; }
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= m; i++) {
scanf("%d%d%d%d", &t[i], &l[i], &r[i], &c[i]);
order[i] = i;
dp[i] = inf;
}
sort(order + 1, order + m + 1, cmp);
for (int _i = 1; _i <= m; _i++) {
int i = order[_i];
if (l[i] == 1) {
dp[i] = c[i];
continue;
}
for (int _j = 1; _j < _i; _j++) {
int j = order[_j];
if (min(r[j], r[j] - abs(t[i] - t[j])) >= l[i] - 1)
dp[i] = min(dp[i], dp[j] + c[i]);
}
}
// for (int i = 1; i <= m; i++)
// printf("%lld\n", dp[i]);
ll ans = inf;
for (int i = 1; i <= m; i++)
if (r[order[i]] == n)
ans = min(ans, dp[order[i]]);
if (ans == inf)
printf("%d", -1);
else
printf("%lld\n", 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... |