답안 #3958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3958 2013-08-31T09:43:06 Z shinhj88 King of penalty (kriii1_K) C++
0 / 1
24 ms 2008 KB
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
long P,N;
vector<long> data;
void input()
{
	scanf("%ld%ld",&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;
	for(int i=0;i<N;i++)
	{
		if(P-data[i]<0)
		{
			printf("%d %lld\n",i,P*i+ans);
			return;
		}
		P-=data[i];
		ans+=data[i]*(i+1);		
		sum+=data[i];
	}
	
}
int main()
{
	input();
	process();

}
# 결과 실행 시간 메모리 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 1388 KB Output is correct
5 Correct 0 ms 1236 KB Output is correct
6 Correct 4 ms 1388 KB Output is correct
7 Correct 8 ms 1580 KB Output is correct
8 Correct 12 ms 1616 KB Output is correct
9 Correct 24 ms 2008 KB Output is correct
10 Correct 24 ms 1972 KB Output is correct
11 Incorrect 16 ms 2004 KB Output isn't correct
12 Halted 0 ms 0 KB -