The retirement of "El Pozo"
The Well
In the middle of the Sabadell Institute's courtyard, for more than half a century, there has been a well that has been a silent witness to our center's history. Built in 1960, during the construction of the main building, this well was not just a decorative element - it was the main source of water for the entire institute in those early years, when the neighborhood was just beginning to grow and infrastructure was still precarious.
The most veteran students and teachers remember how, during the first years, the buckets went up and down constantly, providing fresh water for the kitchen, the bathrooms, and even for watering the small garden that was next to the gymnasium. It was precisely a group of students from the 70s who began to call it "The Well." The name quickly took root, and soon everyone knew it that way, becoming a habitual meeting point: "We'll meet at The Well during recess!"
The Well was not only a productive tool for the Institute. It also brought a certain freshness to the center. With its pulley and constant work, The Well always brought water. Not only that, but it helped put out more than one fire that had started in the Institute.
Over the years, when running water was already reaching everywhere, The Well maintained its central role in the life of the institute, now as a symbol and witness to our history. Generations of students have discreetly left their initials engraved on its stone edge, have shared secrets leaning on its walls, and have taken graduation photos around it.
Now, after 60 faithful years, it's time to retire The Well. In this CodeJam, we want to pay tribute to the well. Your challenge? Help us lower a final bucket into The Well!
The passage of time doesn't forgive, and after years of disuse, the interior walls of The Well have become filled with cobwebs. The well has a depth of \(N\) units and a width of \(H\) units, and the cobwebs have formed alternately from the side walls. The first cobweb comes from the left wall, and then they alternate between right and left throughout the entire depth of the well.
We want to lower a final commemorative bucket to the bottom of The Well. The bucket, instead of dodging the cobwebs, will go down in a straight line in a fixed horizontal position, breaking all the cobwebs it finds in its path.
For example, if we have this drawing of The Well (the image corresponds to the second example)
and we lowered the bucket from the 4th position, it would break 8 cobwebs
This is not the optimal solution since if we had lowered it from the first or fifth position, we would only break 7 cobwebs.
Create a program to determine the minimum number of cobwebs that this final commemorative bucket would break, and from how many positions it could be lowered.
Input
The first line contains two integers \(N\) and \(H (2≤N≤200000, 2≤H≤500000)\), where N is the depth of the well and the number of cobwebs, and H is the width of the well. N will always be even.
The following N lines contain the length of each cobweb, one per line. All lengths are positive integers less than H.
Output
A line with two integers separated by a space:
- The minimum number of cobwebs that the bucket will have to break
- The number of different horizontal positions where this minimum can be achieved
Example Input
6 7
1
5
3
3
5
1
Example Output
2 3
Example Input
14 5
1
3
4
2
2
4
3
4
3
3
3
2
3
3
Example Output
7 2
Note
This problem is dedicated to Professor Elena del Pozo (where del Pozo means "of the well" in spanish), who has dedicated her career to teaching and has organized numerous CodeJams that have inspired many students to discover the magic of programming. Her dedication and passion for teaching have left an indelible mark on the Sabadell Institute, just as The Well has been a fundamental part of the history of this fictional center.
Comments
Pongan juez