# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4063 | shinhj88 | King of penalty (kriii1_K) | C++98 | 0 ms | 1236 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 <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int P,N;
vector<int> data;
void input()
{
scanf("%d%d",&P,&N);
data.resize(N+1);
for(int i=0;i<N;i++)
{
scanf("%d",&data[i]);
}
sort(data.begin(),data.end());
}
void process()
{
P--;
long long int ans=0;
int i;
for(i=0;i<=N;i++)
{
if(P-data[i]<0)break;
ans+=P;
P-=data[i];
}
printf("%d %lld\n",i,ans);
}
int main()
{
input();
process();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |