이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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.emplace_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;
ll i=n-1;
while(sum<d&&i>=0)
{
if(i==id)
{
i--;
continue;
}
if(x[i]-d+sum>0)
sum+=x[i]-max((ll)0,(d-sum)),anw++;
i--;
}
if(sum==m)
anw--;
if(sum<d)
{
cout<<0;
return 0;
}
cout<<anw;
return 0;
}
# | 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... |