# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3467 | wurikiji | King of penalty (kriii1_K) | C++98 | 24 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 <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
vector<int> ls;
int main(void){
int n,p;
scanf("%d %d",&p,&n);
ls.clear();
for(int i = 0 ; i< n;i++)
{
int a;
scanf("%d",&a);
ls.push_back(a);
}
sort(ls.begin(),ls.end());
int cnt= 0;
long long sum = 0;
p--;
for(int i = 0 ;i < ls.size();i++)
{
if( p - ls[i] >= 0 )
{
sum += p;
p -= ls[i];
cnt++;
}
}
printf("%d %lld\n",cnt, sum);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |