Submission #754959

#TimeUsernameProblemLanguageResultExecution timeMemory
754959MilosMilutinovicTreatment Project (JOI20_treatment)C++14
0 / 100
3040 ms3020 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...