## DMOPC '15 Contest 2 P5 - Sysadmin

View as PDF

Points: 15 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem types

Every day as the sun sets, quantum opens up his terminal and connects to the DMOJ site server. Like any sysadmin, quantum likes statistics about anything and everything. Today, he's interested in the memory usages of all the applications running on the server.

As he runs top, he notices that programs, identified , appear to have memory leaks. That is, program 's memory usage increases by KB every second, each starting from a distinct KB. Finding this race of programs fun to watch, quantum would like to answer queries: for each query , he'd like to know which program has the greatest memory usage after seconds. There might be multiple, in which case he'd like to know the one with the smallest identifier.

#### Constraints

For all subtasks, , , and .

#### Input Specification

The first line of input will contain the space-separated integers and .
For the next lines of input, line will contain two integers , and .
Finally, the last lines will each contain a query.

#### Output Specification

For each query, the id of the program using the most memory at the given time.

#### Sample Input

2 2
400 100
200 200
1
10

#### Sample Output

0
1

#### Explanation

After the second, program uses KB of memory, while uses only KB. Following seconds, program is in the lead, with KB of memory used.

• commented on Dec. 15, 2015, 5:24 p.m.

What happened to the judge?

• commented on Dec. 15, 2015, 6:12 p.m.

I was updating the software on the Herculaneum judge as well as adding Swift support (seeing as Apple open-sourced it a few days ago). It's back online now, sorry for the delay.

• commented on Nov. 11, 2015, 3:03 p.m. edit 4

• commented on Nov. 22, 2015, 12:12 p.m.

i used scanf and printf and it passed for me.

• commented on Nov. 11, 2015, 3:27 p.m.