Under construction

Still being built. Things may change

Pen Testing

Time limit90sMemory limit1024 MB

Summary
Given N pens holding each ink amount from 0 to N-1 once, find two pens with at least N ink total, using write attempts that drain ink to probe them.
Level

Medium6 of 10

Topics
Greedy, Implementation
Solved
No attempts yet

Problem

You have NN ballpoint pens. Each pen holds a distinct integer number of ink units between 00 and N−1N-1, but the pens are given to you in random order, so you do not know how much ink each pen holds.

You are about to go on a trip to the South Pole, where there are no pens. Your luggage has room for only two pens. You also need to write many important postcards, so the two pens you choose must have a total of at least NN ink units.

The only way to learn about the pens is to pick one and try writing with it. If the write succeeds, that pen loses one unit of ink (and may now be empty). If it fails, the pen already had no ink left. You can repeat this as many times as you like, with the same pen or different pens.

Finally, you choose two pens to take on the trip. You succeed if the total ink remaining in those two pens is at least NN units.

You will be given TT test cases, and you must succeed in at least CC of them. All test data in this problem is visible.

Constraints

N=15N = 15

Examples1

  1. Example 1

    Input
    1
    15
    
    Expected output
    T 1
    T 2
    T 3
    T 4
    T 5
    T 6
    T 7
    T 8
    T 9
    T 10
    T 11
    T 12
    T 13
    T 14
    T 15
    A 1 2