# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28987 | tlwpdus | Taxis (POI13_tak) | C++11 | 196 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;
ll m, d; int n;
ll x[500100];
int main() {
int i;
scanf("%lld%lld%d",&m,&d,&n); m*=2; d*=2;
for (i=0;i<n;i++) {scanf("%lld",&x[i]);x[i]*=2;}
sort(x,x+n);
int idx = lower_bound(x,x+n,m-d)-x;
if (idx==n) {
printf("0\n"); return 0;
}
ll loc = (d-(x[idx]-(m-d))/2), cur = 0; int cnt = 0;
for (i=n-1;i>=0;i--) {
if (cur>=m) {
printf("%d\n",cnt);
return 0;
}
if (cur>=loc) {
printf("%d\n",cnt+1);
return 0;
}
if (i==idx) continue;
if (d-cur>=x[i]) {
printf("0\n");
return 0;
}
cur += (x[i]-(d-cur)); cnt++;
}
if (cur>=m) {
printf("%d\n",cnt);
return 0;
}
if (cur>=loc) {
printf("%d\n",cnt+1);
return 0;
}
printf("0\n");
return 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... |