답안 #12736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
12736 2015-01-02T10:00:52 Z ainu7 King of penalty (kriii1_K) C++
1 / 1
68 ms 2064 KB
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

int main()
{
  int P, N;
  cin >> P >> N;
  long long res = 0;
  int cnt = 0;
  vector<int> V(N);
  for (int i=0; i<N; i++)
    cin >> V[i];
  sort(V.begin(), V.end());

  P --;
  for (int i=0; i<N; i++) {
    if (P >= V[i]) {
      cnt ++;
      res += P;
      P -= V[i];
    }
  }
  cout << cnt << " " << res << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1676 KB Output is correct
2 Correct 0 ms 1676 KB Output is correct
3 Correct 0 ms 1676 KB Output is correct
4 Correct 4 ms 1676 KB Output is correct
5 Correct 0 ms 1676 KB Output is correct
6 Correct 4 ms 1676 KB Output is correct
7 Correct 20 ms 1848 KB Output is correct
8 Correct 28 ms 1868 KB Output is correct
9 Correct 68 ms 2064 KB Output is correct
10 Correct 68 ms 2044 KB Output is correct
11 Correct 32 ms 2064 KB Output is correct
12 Correct 24 ms 2044 KB Output is correct
13 Correct 0 ms 1676 KB Output is correct
14 Correct 4 ms 1676 KB Output is correct
15 Correct 24 ms 2056 KB Output is correct