답안 #18600

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18600 2016-02-10T14:07:58 Z eaststar King of penalty (kriii1_K) C++14
1 / 1
32 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);
    for(i=1;i<=n;++i){
        if(t+a[i]>=p)break;
        t+=a[i];
    }
    p-=t+1,t=0;
    for(n=--i;i;--i)t+=a[i],s+=t;
    printf("%d %lld",n,(long long)p*n+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 0 ms 1472 KB Output is correct
7 Correct 12 ms 1472 KB Output is correct
8 Correct 12 ms 1472 KB Output is correct
9 Correct 32 ms 1472 KB Output is correct
10 Correct 31 ms 1472 KB Output is correct
11 Correct 19 ms 1472 KB Output is correct
12 Correct 4 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 7 ms 1472 KB Output is correct