Submission #3571

# Submission time Handle Problem Language Result Execution time Memory
3571 2013-08-31T06:38:18 Z hyeonjae0310 King of penalty (kriii1_K) C++
1 / 1
72 ms 2444 KB
#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
1 Correct 0 ms 1672 KB Output is correct
2 Correct 0 ms 1672 KB Output is correct
3 Correct 0 ms 1672 KB Output is correct
4 Correct 8 ms 1824 KB Output is correct
5 Correct 0 ms 1672 KB Output is correct
6 Correct 8 ms 1824 KB Output is correct
7 Correct 24 ms 2016 KB Output is correct
8 Correct 28 ms 2052 KB Output is correct
9 Correct 72 ms 2444 KB Output is correct
10 Correct 68 ms 2408 KB Output is correct
11 Correct 32 ms 2444 KB Output is correct
12 Correct 20 ms 2408 KB Output is correct
13 Correct 0 ms 1672 KB Output is correct
14 Correct 4 ms 1672 KB Output is correct
15 Correct 24 ms 2428 KB Output is correct