Submission #29461

#TimeUsernameProblemLanguageResultExecution timeMemory
29461kdh9949Taxis (POI13_tak)C++14
30 / 100
176 ms5924 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, t; 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>()); for(; t < n && a[t] >= d - b; t++); t--; int cnt = 0; for(int i = 0; i < n; i++){ if(i == t) continue; if(x <= b) x += max(0LL, a[i] - (b - x)); else x = max(x, b + a[i]); cnt++; if(x >= d){ printf("%d\n", cnt); return 0; } if(a[t] >= max(d - b, b + d - 2 * x)){ printf("%d\n", cnt + 1); 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...