Programming contests

DEIK Regionális Programozó Csapatverseny, középiskolai kategória, 2018. december 9.

December 9, 2018, 10:20 AM – December 9, 2018, 3:20 PM

J — You Are Fired!

The latest quarterly report of the Pump Organization does not look promising at all: the costs exploded, while the revenue decreased by 42%. Taking a closer look at the numbers, CEO Dagobert J. Pump comes to the conclusion that the only way to save the company is to fire some of the employees.

The problem is that CEO Pump just recently claimed in an interview that “he is the greatest job creator that God ever created”. So if he fired too many people, the dishonest corrupted left-wing media would certainly report about it, which would make him look extremely unreliable. The PR experts of the Pump Organization already estimated a number of employees that CEO Pump may fire without raising any attention in the media. To be on the safe side, CEO Pump further decides to fire as few employees as possible.

Taking a list of all employees of his company and their respective salaries, CEO Pump has to save at least d dollars by firing not more than k employees. If this is possible, CEO Pump wants to personally tell each and every one of them: YOU ARE FIRED!

Input Specification

The input consists of:

  • one line with three integers n, d, and k, where
    • n (1 ≤ n ≤ 10 000) is the number of employees of the Pump Organization;
    • d (1 ≤ d ≤ 109) is the amount of money that CEO Pump needs to save at least;
    • k (1 ≤ k ≤ n) is the maximum number of employees that CEO Pump can fire without raising attention in the media;
  • n lines, each containing a string si and an integer ci, where
    • si (1 ≤ |si| ≤ 7) is the name of the ith employee;
    • ci (1 ≤ ci ≤ 100 000) is the salary of the ith employee.

All si's are distinct and only contain lowercase and uppercase letters of the English alphabet.

Output Specification

If there is no way to save at least d dollars by firing not more than k employees, output “impossible”.

If there is a way to save at least d dollars by firing not more than k employees, then the output should consist of:

  • one line containing a single integer x (1 ≤ x ≤ k), where x is the number of people to be fired;
  • x lines, each containing the string “si, YOU ARE FIRED!”, where si is the name of the ith employee to be fired.

If there are multiple solutions, any of them will be accepted.

Sample Input 1

  1. 5 2000 3
  2. John 999
  3. Lyndon 450
  4. Richard 1234
  5. Gerald 1001
  6. Jimmy 300
download as text file

Output for Sample Input 1

  1. 2
  2. Richard, YOU ARE FIRED!
  3. Gerald, YOU ARE FIRED!
download as text file

Sample Input 2

  1. 3 5555 2
  2. Ronald 1000
  3. George 2000
  4. Bill 3000
download as text file

Output for Sample Input 2

  1. impossible
download as text file

Original Problem

ACM ICPC 2017 German Collegiate Programming Contest

University of Debrecen; Faculty of Informatics; v. 09/30/2024