# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
36597 | WhipppedCream | Taxis (POI13_tak) | C++14 | 193 ms | 5920 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>
//#ifdef atom #else #endif
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define X first
#define Y second
#define vi vector<int>
#define vvi vector< vi >
#define vii vector< ii >
#define mp make_pair
#define pb push_back
const int maxn = 5e5+5;
ll x[maxn];
int n;
ll d, m;
int LU(ll k)
{
return lower_bound(x, x+n, k)-x;
}
void fail()
{
puts("0");
exit(0);
}
void use(ll x)
{
int dd = min(d, x-d);
d -= dd;
m -= dd;
}
bool ok(ll x)
{
return x>=d+m;
}
int main()
{
//#ifndef atom
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
//#endif
scanf("%lld %lld %d", &m, &d, &n);
for(int i = 0; i< n; i++) scanf("%lld", &x[i]);
sort(x, x+n);
//if(2*d< m)
//{
int pos = LU(m-d);
if(pos == n) fail();
int cnt = 0;
for(int i = n-1; i>= 0; i--)
{
if(i == pos) continue;
if(d>x[i]) fail();
if(ok(x[max(pos, i)]))
{
printf("%d\n", cnt+1);
return 0;
}
use(x[i]); cnt++;
//cout << m << " " << d << endl;
}
//}
if(ok(x[pos])) printf("%d\n", cnt+1);
else printf("0\n");
}
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... |