# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29461 | kdh9949 | Taxis (POI13_tak) | C++14 | 176 ms | 5924 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |