Submission #117083

#TimeUsernameProblemLanguageResultExecution timeMemory
117083arman_ferdousPinball (JOI14_pinball)C++14
0 / 100
2 ms384 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 1e5+100; int n, m, a[N], b[N], c[N], Del[N]; ll d[N]; vector< pair<ll,int> > v; int dfs(int u, int lev) { if(lev == n + 2) return u; if(Del[lev]) return dfs(u, lev + 1); if(a[lev] <= u && u <= b[lev]) return dfs(c[lev], lev + 1); return dfs(u, lev + 1); } bool ok() { return dfs(1, 1) == dfs(m, 1); } int main() { scanf("%d %d", &n, &m); for(int i = 2; i < n + 2; i++) { scanf("%d %d %d %lld", &a[i], &b[i], &c[i], &d[i]); v.push_back({-d[i], i}); } sort(v.begin(), v.end()); ll ans = 0; for(int i = 0; i < n; i++) { Del[v[i].second] = 1; if(!ok()) ans -= v[i].first, Del[v[i].second] = 0; } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

pinball.cpp: In function 'int main()':
pinball.cpp:23: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:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %lld", &a[i], &b[i], &c[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...