# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3973 | zzapcoder | King of penalty (kriii1_K) | C++98 | 0 ms | 1672 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<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
int n,p;
cin>>p>>n;
vector<int> vll(n,0);
for(int i=0;i<n;++i) cin>>vll[i];
sort(vll.begin(), vll.end());
int leftTime = p-1;
long long ans = 0, idx = 0;
while( leftTime >= 0 ){
if(idx < vll.size() && vll[idx] <= leftTime){
ans += leftTime;
leftTime -= vll[idx];
idx++;
}
else break;
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |