# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29467 | kdh9949 | Taxis (POI13_tak) | C++14 | 199 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, cnt, 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);
ans = n + 1;
sort(a, a + n, greater<int>());
for(int i = 0; i < n; i++){
if(x <= b) x += max(0LL, a[i] - (b - x));
else x = max(x, b + a[i]);
cnt++;
if(x >= d){
ans = min(ans, cnt);
break;
}
}
for(; t < n && a[t] >= d - b; t++); t--;
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){
ans = min(ans, cnt);
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... |