답안 #3969

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3969 2013-08-31T09:47:38 Z pmpmp King of penalty (kriii1_K) C++
1 / 1
32 ms 3240 KB

#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

/*typedef struct{
    int x, y, n, nn;
}tree;
tree h[101];
int hx[101], hy[101];

bool cmp(tree a, tree b){ return a.n>b.n; }*/
bool cmpx(int a, int b){ return a<b; }
long long h[100005], s[100005], sum;

int main ()
{
    
   ////// freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
    
    int a, b, c;
    int i, j, k, t;
    scanf("%d %d", &a, &b);
    for(i=0;i<b;i++){scanf("%lld", &h[i]);} 
    sort(h,h+b,cmpx); s[0]=h[0];
    for(i=1;i<b;i++){s[i]=s[i-1]+h[i];}
    for(i=0;i<b;i++)
    {
         if(s[i]>a-1){break;}
         sum=sum+(a-1-s[i])+h[i]; if(i==b-1){i++; break;}
    } //if(i==b){i--;}
    printf("%d %lld", i, sum);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3240 KB Output is correct
2 Correct 0 ms 3240 KB Output is correct
3 Correct 0 ms 3240 KB Output is correct
4 Correct 0 ms 3240 KB Output is correct
5 Correct 0 ms 3240 KB Output is correct
6 Correct 4 ms 3240 KB Output is correct
7 Correct 12 ms 3240 KB Output is correct
8 Correct 12 ms 3240 KB Output is correct
9 Correct 32 ms 3240 KB Output is correct
10 Correct 28 ms 3240 KB Output is correct
11 Correct 20 ms 3240 KB Output is correct
12 Correct 16 ms 3240 KB Output is correct
13 Correct 0 ms 3240 KB Output is correct
14 Correct 0 ms 3240 KB Output is correct
15 Correct 16 ms 3240 KB Output is correct