답안 #3443

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3443 2013-08-31T05:49:18 Z pl0892029 King of penalty (kriii1_K) C++
1 / 1
24 ms 1476 KB
#include <cstdio>
#include <algorithm>

using namespace std;
int Problem[100000];

int main() {
 int P, N;
 scanf("%d %d",&P,&N);

 for(int i=0;i<N;i++)
  scanf("%d",Problem+i);
 
 sort(Problem,Problem+N);

 int sum = 0, idx = 0;
 for(int i=0;i<N;i++) {
  sum += Problem[i];

  if(sum >= P)
   break;

  idx = i;
 }

 printf("%d ",idx+1); // Maximum solving problems

 for(int i=idx-1;i>=0;i--)
  Problem[i] += Problem[i+1];
 
 long long panelty = 0;

 for(int i=idx;i>=0;i--)
  panelty += Problem[i] + P-Problem[0]-1;

 printf("%lld",panelty);
}

# 결과 실행 시간 메모리 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 8 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 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