Submission #754958

# Submission time Handle Problem Language Result Execution time Memory
754958 2023-06-09T06:36:01 Z MilosMilutinovic Treatment Project (JOI20_treatment) C++14
0 / 100
3000 ms 6216 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 r[i] < r[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

treatment.cpp: In function 'int main()':
treatment.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
treatment.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d%d%d%d", &t[i], &l[i], &r[i], &c[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 3058 ms 6216 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 304 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 304 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3058 ms 6216 KB Time limit exceeded
2 Halted 0 ms 0 KB -