답안 #3460

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3460 2013-08-31T05:56:07 Z zzapcoder King of penalty (kriii1_K) C++
0 / 1
24 ms 1976 KB
#include <stdio.h>
#include <vector>
#include <algorithm>
int P, N;
std::vector<int> T;
bool compare(int a, int b)
{
	if ( a < b )
		return true;
	else
		return false;
}
int main()
{
	scanf("%d %d\n", &P, &N);
	
	for ( int i = 0 ; i < N ; i ++)
	{
		int tmp;
		scanf("%d", &tmp);
		T.push_back(tmp);
	}

	sort(T.begin(), T.end());

	int i = 0;
	int sum = 0;
	P -= 1;
	while ( P - T[i] >= 0 )
	{
		sum += P;
		P = P - T[i];
		i++;
	}
	printf("%d %d",i, sum);
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1204 KB Output is correct
2 Correct 0 ms 1204 KB Output is correct
3 Correct 0 ms 1204 KB Output is correct
4 Correct 4 ms 1336 KB Output is correct
5 Correct 0 ms 1204 KB Output is correct
6 Correct 4 ms 1336 KB Output is correct
7 Correct 8 ms 1592 KB Output is correct
8 Correct 4 ms 1592 KB Output is correct
9 Incorrect 24 ms 1976 KB Output isn't correct
10 Halted 0 ms 0 KB -