Submission #29441

#TimeUsernameProblemLanguageResultExecution timeMemory
29441kdh9949Taxis (POI13_tak)C++14
40 / 100
219 ms5924 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, t, ans; ll d, b, x, a[500010]; int main(){ scanf("%lld%lld%d", &d, &b, &n); for(int i = 0; i < n; i++) scanf("%lld", a + i); sort(a, a + n, greater<int>()); t = int(upper_bound(a, a + n, d - b, greater<int>()) - a - 1); for(int i = 0; i < n; i++){ if(i == t) continue; if(a[i] >= b + d - 2 * x){ printf("%d\n", i + (i < t)); return 0; } x += max(0LL, a[i] - (b - x)); x = min(x, b); if(a[t] >= b + d - 2 * x){ printf("%d\n", i + 1 + (i < t)); return 0; } } puts("0"); }

Compilation message (stderr)

tak.cpp: In function 'int main()':
tak.cpp:9:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%d", &d, &b, &n);
                                 ^
tak.cpp:10:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i < n; i++) scanf("%lld", a + 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...