|
Fuuka |
Everything was going so well. For once... |
|
Fuuka |
It was a holiday, so I slept well. I finished preparing breakfast before leaving, and the food turned out fine. |
|
Fuuka |
I had even put on my kimono and was just about to go make my first shrine visit of the year... |
|
Fuuka |
And yet... And yet... |
|
Fuuka |
Why is it always me!!! |
The first line contains the number of test cases .
Each test case consists of the following three lines.
For each test case, print the maximum achievable satisfaction and the minimum number of restaurants that must be blown up to achieve it, separated by a space on one line.
Juri
|
Senpai... |
|
Haruna |
Life does have a way of refusing to go as one wishes. |
|
Haruna |
Countless trials come our way. We overcome them, only for more to arrive, and overcome those in turn... |
|
Haruna |
Humanity is, in that sense, something to be overcome... |
|
Fuuka |
That sounds pretty strange coming from the person who kidnapped us... |
|
Haruna |
Now then, shall we get down to business? |
|
Haruna |
The reason our Gourmet Research Society went to such lengths to bring you here is that there is something we simply must ask you to do. |
|
Fuuka |
You did not bring us here... You kidnapped us... |
|
Fuuka |
Though it happens so often, I am almost getting used to it... |
I hope you are well. Haruna here. It has already been a week since our New Year’s adventure.
To summarize last week’s events, our New Year’s commotion was a tale of the Gourmet Research Society taking on the giant food distributor Nyao Foods, driven solely by our passion for delicious food, to protect the little restaurant Sparrow from closure. When Nyao Foods sought to acquire it and turn it into a chain restaurant, we accepted a cooking contest with the restaurant’s fate at stake. Even the Gourmet Helmet Gang became involved, turning an entire corner of the city upside down. In the end, after our showdown, Sparrow survived with its character intact. And today, we have gained a wonderful new goal: to find more hidden gems like it and share them with the world.
Our Gourmet Research Society has carefully selected restaurants. We have noted that the -th restaurant has a deliciousness value of . We are planning a tour that visits restaurants through in order. If a restaurant does not meet our standards... we intend to blow it up beforehand. We may choose several of the restaurants to blow up, then close the gaps while preserving the order of the remaining restaurants. Oh, a tour without eating would be unthinkable, so we must leave at least two restaurants intact. As we visit the remaining restaurants in order, we will consider whether the food becomes more delicious along the way.
Incidentally, the Prefect Team may be guarding some restaurants... Fortunately, we have already obtained that information. If , we may blow up restaurant . If , however, I am afraid we cannot blow it up. We would not want to spoil our special gourmet tour, after all. Heehee.
For each pair of consecutively visited restaurants, if the next restaurant is more delicious than the previous one, our spirits will rise by the difference in their deliciousness. Conversely, if it is less delicious, our spirits will fall by that amount. Let us call the sum of all these signed differences in deliciousness between adjacent restaurants throughout the tour our satisfaction. I wonder what the maximum satisfaction we can achieve is. Still, we would like to enjoy as much variety as possible, so among tours with maximum satisfaction, we would like to minimize the number of restaurants blown up.
To define satisfaction precisely... suppose restaurants remain, and the -th of them has deliciousness . Then satisfaction is
as you see.
Now, Sensei. Let us find the maximum satisfaction and the minimum number of restaurants we must blow up to achieve it.
The sum of over all test cases does not exceed .