# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
754959 | 2023-06-09T06:42:13 Z | MilosMilutinovic | Treatment Project (JOI20_treatment) | C++14 | 3000 ms | 3020 KB |
#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; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3040 ms | 3020 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3040 ms | 3020 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |