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;
#define fast ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
#define f first
#define s second
#define LOGN 20
const ll MOD = 998244353;
const ll MAXN = 1e5 + 100;
#define int long long
vector<ll> x;
signed main() {
fast
ll m, d, n;
cin >> m >> d >> n;
x = vector<ll>(n);
for (int i = 0; i < n; i++)
cin >> x[i];
sort(x.begin(), x.end());
auto it = lower_bound(x.begin(), x.end(), m - d);
if (it == x.end()) {
cout << "0\n";
return 0;
}
int goal = d + (m - d - *it) / 2;
x.erase(it);
int cnt = 1;
int plc = 0;
while (x.size()) {
int now = x.back();
x.pop_back();
if (now <= d - plc)
break;
plc += now - d + plc;
cnt++;
if (plc >= goal)
break;
}
cout << (plc < goal ? 0 : cnt) << "\n";
}
# | 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... |