Submission #3386

# Submission time Handle Problem Language Result Execution time Memory
3386 2013-08-31T05:15:32 Z joinsung King of penalty (kriii1_K) C++
0 / 1
72 ms 2444 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int p, n;
  cin >> p >> n;
  vector<int> time;
  for (int ni=0;ni<n;ni++) {
    int t;
    cin >> t;
    time.push_back(t);
  }
  sort(time.begin(), time.end());
  int penalty = 0;
  int t = p-1;
  int count = 0;
  for (int ni=0;ni<n;ni++) {
    t -= time[ni];
    if (t < 0)
      break;
    penalty += t + time[ni];
    count++;
  }
  cout << count << " " << penalty << endl;
  return 0;
}
# Verdict Execution time Memory 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 8 ms 1804 KB Output is correct
5 Correct 0 ms 1672 KB Output is correct
6 Correct 8 ms 1804 KB Output is correct
7 Correct 24 ms 2060 KB Output is correct
8 Correct 28 ms 2060 KB Output is correct
9 Incorrect 72 ms 2444 KB Output isn't correct
10 Halted 0 ms 0 KB -