electicode
HomeCoursesResourcesProblemsNational OlympiadContestsLeaderboard
...

Balloonburst

Time Limit: 1000msMemory Limit: 256MB
View Submissions

Problem Description

You are given nnn balloons inside a hall. The ceiling of the hall is at a height of hhh meters. Each balloon initially floats at height aia_iai​ meters and rises upward at a constant rate of viv_ivi​ meters per second. A balloon bursts the moment it reaches or exceeds the ceiling height hhh. You are also given a duration ttt in seconds. Your task is to determine:

  • How many balloons do not burst after ttt seconds?
  • Among the balloons that do not burst, print the index of the one that is at the maximum height. If multiple balloons have the same maximum height, choose the one with the largest index. If no balloons remain unburst, print 0 -1.

Input Format

The first line contains three integers nnn, hhh, and ttt --- the number of balloons, the height of the ceiling, and the time in seconds. Each of the next nnn lines contains two integers aia_iai​ and viv_iv --- the initial height and the upward velocity of the -th balloon.

Constraints:

  • 1≤n,t≤1051 \leq n, t \leq 10^51≤n,t≤105
  • 0≤ai<h≤1090 \leq a_i < h \leq 10^90≤ai​<

Output Format

Print a single line containing two space-separated integers: the number of balloons that do not burst after ttt seconds, and the index of the highest unburst balloon (or −1-1−1 if there are none).

Scoring

SubtaskAdditional ConstraintsPointsRequired Subtask
000Tests from the example000-
111n=1n = 1n= and

Examples

Example 1
Input
4 10 2
2 3
3 2
5 3
4 1
Output
3 1
Example 2
Input
2 4 2
0 2
2 1
Output
0 -1
Example 3
Input
2 5 2
0 2
2 1
Output
2 2

© 2026 Electicode. All rights reserved.

i​
iii
h
≤
109
  • 1≤vi≤1041 \leq v_i \leq 10^41≤vi​≤104
  • 1
    a1=0a_1 = 0a1​=0
    151515
    -
    222n=1n = 1n=1202020111
    333ai=0a_i = 0ai​=0 for all iii252525111
    444No additional constraints404040000, 111, 222, 333