답안 #3599

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3599 2013-08-31T06:49:32 Z arine King of penalty (kriii1_K) C++
1 / 1
24 ms 1868 KB
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long int lld;

lld P, N, data[100005];

int main() {

    scanf("%lld %lld", &P, &N);
    for(int i=0; i<N; ++i) scanf("%lld", &data[i]);

    sort(data, data+N);

    int T=P-1;
    lld ans=0, pan=0;
    for(int i=0; i<N; ++i) {
        if(T-data[i]<0) break;
        ++ans;

        T-=data[i];
        pan+=data[i]+T;
    }   

    printf("%lld %lld", ans, pan);

    return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1868 KB Output is correct
2 Correct 0 ms 1868 KB Output is correct
3 Correct 0 ms 1868 KB Output is correct
4 Correct 4 ms 1868 KB Output is correct
5 Correct 0 ms 1868 KB Output is correct
6 Correct 4 ms 1868 KB Output is correct
7 Correct 8 ms 1868 KB Output is correct
8 Correct 8 ms 1868 KB Output is correct
9 Correct 24 ms 1868 KB Output is correct
10 Correct 20 ms 1868 KB Output is correct
11 Correct 12 ms 1868 KB Output is correct
12 Correct 12 ms 1868 KB Output is correct
13 Correct 0 ms 1868 KB Output is correct
14 Correct 0 ms 1868 KB Output is correct
15 Correct 12 ms 1868 KB Output is correct