제출 #3535

#제출 시각아이디문제언어결과실행 시간메모리
3535hyeonjae0310King of penalty (kriii1_K)C++98
0 / 1
72 ms2064 KiB
#include <iostream>
#include <algorithm>

using namespace std;

int a[100000];

int main()
{
	int p,n;
	int i;
	int tot;
	cin>>p>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	tot=0;
	i=0;
	p--;
	while(p-a[i]>0)
	{
		tot+=p;
		p-=a[i];
		i++;
	}
	cout<<i<<' '<<tot;
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...