#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,d,anw=1,sum,id;
vector<ll> x;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cin>>m>>d>>n;
for(int i=0;i<n;i++)
{
ll a;cin>>a;
x.push_back(a);
}
sort(x.begin(),x.end());
id=lower_bound(x.begin(),x.end(),m-d)-x.begin();
if(id==n)
{
cout<<0;
return 0;
}
if(m==d)
anw=0,id=-1;
// find x try to be exact
ll i=n-1;
while(sum<d&&i>=0)
{
if(i==id) continue;
if(x[i]-d+sum>0)
sum+=x[i]-d+sum,anw++;
i--;
}
if(sum<d)
{
cout<<0;
return 0;
}
cout<<anw;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Execution timed out |
1061 ms |
256 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1083 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Execution timed out |
1060 ms |
384 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1024 KB |
Output is correct |
2 |
Execution timed out |
1085 ms |
1024 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
1532 KB |
Output is correct |
2 |
Execution timed out |
1058 ms |
1532 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
1532 KB |
Output is correct |
2 |
Execution timed out |
1062 ms |
2544 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
99 ms |
4584 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1057 ms |
4568 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
109 ms |
4584 KB |
Output is correct |
2 |
Execution timed out |
1057 ms |
4584 KB |
Time limit exceeded |