답안 #4182

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
4182 2013-09-03T06:25:29 Z hsswill King of penalty (kriii1_K) C++
0 / 1
24 ms 1476 KB
#include<stdio.h>
#include<algorithm>

using std::sort;

int data[100011];

int main(void)
{
	int a, i, sum, n, t = 0, result, r = 0;
	
	scanf("%d %d",&a,&n);

	for(i = 0; i < n; i++)
		scanf("%d",&data[i]);

	sort( data, data+n );
	sum = 0;

	for(i = 0; i < n; i++) 
	{
		r = sum;
		sum += data[i];
		if( sum >= a ) break; 
	}
	if( sum < a ) r = sum;
	r = a-r-1;
	result = i; 
	t = 0;
	sum = r; 
	for(i = result-1; i >= 0; i--) 
	{
		sum += data[i];
		t += sum;
	}
	printf("%d %d",result,t);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1476 KB Output is correct
2 Correct 0 ms 1476 KB Output is correct
3 Correct 0 ms 1476 KB Output is correct
4 Correct 0 ms 1476 KB Output is correct
5 Correct 0 ms 1476 KB Output is correct
6 Correct 4 ms 1476 KB Output is correct
7 Correct 8 ms 1476 KB Output is correct
8 Correct 8 ms 1476 KB Output is correct
9 Incorrect 24 ms 1476 KB Output isn't correct
10 Halted 0 ms 0 KB -