이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |