Submission #4277

# Submission time Handle Problem Language Result Execution time Memory
4277 2013-09-11T03:25:50 Z girl4930 King of penalty (kriii1_K) C++
1 / 1
20 ms 1476 KB
#include<stdio.h>

#include<algorithm>


using namespace std;


int farr[100000];


int main(){

    int p=0, n=0;

    long long sum=0, tmp=0;

    int count=0, i=0;


    scanf("%d %d",&p,&n);

    

    for(i=0;i<n;i++)

        scanf("%d",&farr[i]);


    sort(farr,farr+n);


    for(i=0;i<n;i++) {

        if( tmp + farr[i] >= p ) break;

        tmp = tmp + farr[i];

    }


    tmp = p-tmp-1;

    count = i;


    for( i= i-1;i>=0;i--){

        tmp = tmp+farr[i];

        sum = sum+tmp;

    }


    printf("%d %lld",count,sum);

}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 1476 KB Output is correct
2 Correct 0 ms 1476 KB Output is correct
3 Correct 0 ms 1476 KB Output is correct
4 Correct 0 ms 1476 KB Output is correct
5 Correct 0 ms 1476 KB Output is correct
6 Correct 4 ms 1476 KB Output is correct
7 Correct 4 ms 1476 KB Output is correct
8 Correct 12 ms 1476 KB Output is correct
9 Correct 16 ms 1476 KB Output is correct
10 Correct 20 ms 1476 KB Output is correct
11 Correct 16 ms 1476 KB Output is correct
12 Correct 12 ms 1476 KB Output is correct
13 Correct 0 ms 1476 KB Output is correct
14 Correct 0 ms 1476 KB Output is correct
15 Correct 12 ms 1476 KB Output is correct