Submission #103048

#TimeUsernameProblemLanguageResultExecution timeMemory
103048luciocfPinball (JOI14_pinball)C++14
51 / 100
8 ms640 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3+10; const long long inf = 2e18+10; typedef long long ll; int l[maxn], r[maxn], p[maxn], d[maxn]; ll dp[2][maxn]; int main(void) { int n, m; scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) { scanf("%d %d %d %d", &l[i], &r[i], &p[i], &d[i]); dp[0][i] = dp[1][i] = inf; } for (int i = 1; i <= n; i++) { if (l[i] == 1) dp[0][i] = d[i]; for (int j = i-1; j >= 1; j--) if (p[j] >= l[i] && p[j] <= r[i]) dp[0][i] = min(dp[0][i], 1ll*d[i]+dp[0][j]); } for (int i = 1; i <= n; i++) { if (r[i] == m) dp[1][i] = d[i]; for (int j = i-1; j >= 1; j--) if (p[j] >= l[i] && p[j] <= r[i]) dp[1][i] = min(dp[1][i], 1ll*d[i]+dp[1][j]); } ll ans = inf; for (int i = 1; i <= n; i++) if (dp[0][i] != inf && dp[1][i] != inf) ans = min(ans, dp[0][i]+dp[1][i]-1ll*d[i]); if (ans == inf) printf("-1\n"); else printf("%lld\n", ans); }

Compilation message (stderr)

pinball.cpp: In function 'int main()':
pinball.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
pinball.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %d", &l[i], &r[i], &p[i], &d[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...