답안 #18855

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18855 2016-02-16T03:43:36 Z Namnamseo King of penalty (kriii1_K) C++14
1 / 1
25 ms 1472 KB
#include <cstdio>
#include <algorithm>
using namespace std;
int p,n;
int data[100010];
int main()
{
    scanf("%d%d",&p,&n);
    int i;
    for(i=0;i<n;++i) scanf("%d",data+i);
    sort(data,data+n);
    int cs=0;
    for(i=0;i<n;++i){
        if(data[i]+cs>=p) break;
        else cs+=data[i];
    }
    printf("%d ",i);
    int j;
    typedef long long ll;
    ll ans=0, tmp=p-1-cs;
    for(j=i-1;j>=0;--j){
        tmp+=data[j];
        ans+=tmp;
    }
    printf("%lld\n",ans);
    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 0 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 8 ms 1472 KB Output is correct
8 Correct 13 ms 1472 KB Output is correct
9 Correct 18 ms 1472 KB Output is correct
10 Correct 25 ms 1472 KB Output is correct
11 Correct 18 ms 1472 KB Output is correct
12 Correct 7 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 9 ms 1472 KB Output is correct