LCC '22 Contest 1 S1 - Candy Eggs

View as PDF

Submit solution

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

Author:
Problem type

After choosing to give out trail mix on Halloween, you have become the infamous "healthy candy giver"! The entire town is now throwing eggs at you while you try to walk along the street.

The street is L metres long and W metres wide (imagine a 2D grid with 1-metre rows and columns).

Every row has an angry citizen standing at the left edge of the street that will throw exactly 1 egg across the row (towards the right) to try to hit you.

They might not all throw at the same time. From the moment you start walking, a citizen who is positioned in the ith row will wait a_i seconds before throwing their egg. The eggs fly rightwards at 1 metre per second. (i.e., t seconds after your start walking, egg i should be in column t - a_i).

You walk vertically upwards in a single column of your choice, starting at the bottom, at 1 metre per second (i.e. t seconds after you start walking, you should be in row t). If columns are numbered 1 \ldots W from left to right, which column number should you walk along to be hit by the least number of eggs?

Final Street Diagram

Constraints

In all test cases, 1 \leq L, W \leq 2 \times 10^5, 0 \leq a_i \leq 2 \times 10^5

Subtask 1 [50%]

L, W, a_i \leq 10^3

Subtask 2 [50%]

No further constraints.

Input Specification

First line: L, and W: the length and width (rows and columns) of the street in metres respectively. Second line: a_1 \ldots a_L: the number of seconds that pass before the each citizen throws their egg.

Output Specification

Two integers on one line: the least number of egg hits, and the column number you should stand in. In the case of a tie, choose the column farther from the left edge aka. the higher column number (those guys are scary!).

Sample Input

5 2
0 1 1 2 4

Sample Output

2 2
Explanation for Sample Case

Explanation for Sample Case

(X denotes the places where he would be hit by an egg)

If he stands in column 1, he gets hit by citizens in rows 1, 2 and 5.

If he stands in column 2, he gets hit by citizens in rows 3, and 4.


Comments

There are no comments at the moment.