# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3571 | hyeonjae0310 | King of penalty (kriii1_K) | C++98 | 72 ms | 2444 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 <algorithm>
#include <vector>
using namespace std;
int main()
{
int n;
int i;
long long int p, tot;
cin>>p>>n;
vector<long long int> a(n+1,1000000001);
for(i=0;i<n;i++)
{
cin>>a[i];
}
sort(a.begin(),a.end()-1);
tot=0;
i=0;
p--;
while(p-a[i]>=0)
{
tot+=p;
p-=a[i];
i++;
}
cout<<i<<' '<<tot;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |