답안 #3568

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3568 2013-08-31T06:37:38 Z waps12b King of penalty (kriii1_K) C++
0 / 1
24 ms 1868 KB
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
ll val[100000];
int main() {
	ll P, N;
	scanf("%lld%lld", &P, &N);

	for(int i = 0 ; i < N ; i++) scanf("%lld\n", &val[i]);

	sort(val, val+N);
	ll cur = P-1, ans = 0, ans_n = 0;
	for(int i = 0 ; ; i++) {
		if( cur >= val[i] ) {
			ans_n++;
			ans += cur;
			cur -= val[i];
		}
		else break;
	}
	printf("%lld %lld\n", ans_n, ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1868 KB Output is correct
2 Correct 0 ms 1868 KB Output is correct
3 Correct 0 ms 1868 KB Output is correct
4 Correct 4 ms 1868 KB Output is correct
5 Correct 0 ms 1868 KB Output is correct
6 Correct 4 ms 1868 KB Output is correct
7 Correct 4 ms 1868 KB Output is correct
8 Correct 12 ms 1868 KB Output is correct
9 Correct 24 ms 1868 KB Output is correct
10 Correct 20 ms 1868 KB Output is correct
11 Incorrect 12 ms 1868 KB Output isn't correct
12 Halted 0 ms 0 KB -