답안 #5363

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
5363 2014-04-12T01:45:21 Z baneling100 King of penalty (kriii1_K) C++
1 / 1
24 ms 1476 KB
#include <stdio.h>
#include <algorithm>

using namespace std;

int p, n, t[100001], cnt;
long long ans;

void input(void)
{
    int i;

    scanf("%d %d",&p,&n);
    for(i=1 ; i<=n ; i++)
        scanf("%d",&t[i]);
    sort(t+1,t+n+1);
}

void process(void)
{
    int i;

    p--;
    for(i=1 ; i<=n ; i++)
    {
        if(p>=t[i])
        {
            cnt++;
            ans+=p;
            p-=t[i];
        }
        else
            break;
    }
}

void output(void)
{
    printf("%d %lld",cnt,ans);
}

int main(void)
{
    input();
    process();
    output();

    return 0;
}
# 결과 실행 시간 메모리 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 8 ms 1476 KB Output is correct
9 Correct 24 ms 1476 KB Output is correct
10 Correct 20 ms 1476 KB Output is correct
11 Correct 12 ms 1476 KB Output is correct
12 Correct 8 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