제출 #3571

#제출 시각아이디문제언어결과실행 시간메모리
3571hyeonjae0310King of penalty (kriii1_K)C++98
1 / 1
72 ms2444 KiB
#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 timeMemoryGrader output
Fetching results...