답안 #18601

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18601 2016-02-10T14:10:34 Z eaststar King of penalty (kriii1_K) C++14
1 / 1
31 ms 1472 KB
#include <stdio.h>
#include <algorithm>
using namespace std;
int a[100010],t;
long long s;
int main(){
    int i,p,n;
    scanf("%d%d",&p,&n);
    for(i=1;i<=n;++i)scanf("%d",a+i);
    sort(a+1,a+n+1);
    --p;
    for(i=1;i<=n;++i){
        if(p<a[i])break;
        s+=p;
        p-=a[i];
    }
    printf("%d %lld",--i,s);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1472 KB Output is correct
2 Correct 0 ms 1472 KB Output is correct
3 Correct 0 ms 1472 KB Output is correct
4 Correct 4 ms 1472 KB Output is correct
5 Correct 0 ms 1472 KB Output is correct
6 Correct 4 ms 1472 KB Output is correct
7 Correct 11 ms 1472 KB Output is correct
8 Correct 8 ms 1472 KB Output is correct
9 Correct 31 ms 1472 KB Output is correct
10 Correct 21 ms 1472 KB Output is correct
11 Correct 11 ms 1472 KB Output is correct
12 Correct 10 ms 1472 KB Output is correct
13 Correct 0 ms 1472 KB Output is correct
14 Correct 0 ms 1472 KB Output is correct
15 Correct 14 ms 1472 KB Output is correct