답안 #3424

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3424 2013-08-31T05:42:43 Z joinsung King of penalty (kriii1_K) C++
1 / 1
68 ms 3212 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  long long p, n;
  cin >> p >> n;
  vector<long long> time;
  for (long long ni=0;ni<n;ni++) {
    long long t;
    cin >> t;
    time.push_back(t);
  }
  sort(time.begin(), time.end());
  long long penalty = 0;
  long long t = p-1;
  long long count = 0;
  for (long long ni=0;ni<n;ni++) {
    t -= time[ni];
    if (t < 0)
      break;
    penalty += t + time[ni];
    count++;
  }
  cout << count << " " << penalty << endl;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1672 KB Output is correct
2 Correct 0 ms 1672 KB Output is correct
3 Correct 0 ms 1672 KB Output is correct
4 Correct 4 ms 2060 KB Output is correct
5 Correct 0 ms 1672 KB Output is correct
6 Correct 8 ms 2060 KB Output is correct
7 Correct 24 ms 2444 KB Output is correct
8 Correct 28 ms 2444 KB Output is correct
9 Correct 68 ms 3212 KB Output is correct
10 Correct 60 ms 3212 KB Output is correct
11 Correct 28 ms 3212 KB Output is correct
12 Correct 20 ms 3212 KB Output is correct
13 Correct 0 ms 1672 KB Output is correct
14 Correct 4 ms 1804 KB Output is correct
15 Correct 24 ms 3212 KB Output is correct