Submission #4066

# Submission time Handle Problem Language Result Execution time Memory
4066 2013-08-31T16:37:05 Z shinhj88 King of penalty (kriii1_K) C++
0 / 1
24 ms 1624 KB
#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);
	for(int i=0;i<N;i++)
	{
		scanf("%d",&data[i]);
	}
	sort(data.begin(),data.end());
	
}
void process()
{
	
	P--;
	long long int ans=0,sum=0;
	int i;
	for(i=0;i<N;i++)
	{
		if(P-data[i]<0)break;
		P-=data[i];
		ans=ans+data[i]*(i+1);
		
	}
	printf("%d %lld\n",i,P*i+ans);

	
}
int main()
{
	input();
	process();

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1236 KB Output is correct
2 Correct 0 ms 1236 KB Output is correct
3 Correct 0 ms 1236 KB Output is correct
4 Correct 4 ms 1236 KB Output is correct
5 Correct 0 ms 1236 KB Output is correct
6 Correct 4 ms 1236 KB Output is correct
7 Correct 8 ms 1408 KB Output is correct
8 Correct 8 ms 1428 KB Output is correct
9 Correct 24 ms 1624 KB Output is correct
10 Correct 16 ms 1604 KB Output is correct
11 Incorrect 16 ms 1624 KB Output isn't correct
12 Halted 0 ms 0 KB -