[Solution] Working Week Codeforces Solution
Your working week consists of days numbered from to , after day goes day again. And of them are days off. One of the days off is the last day, day . You have to decide when the other two are.
Choosing days off, you pursue two goals:
- No two days should go one after the other. Note that you can't make day a day off because it follows day .
- Working segments framed by days off should be as dissimilar as possible in duration. More specifically, if the segments are of size , , and days long, you want to maximize .
Output the maximum value of that can be obtained.
The first line of the input contains a single integer () — the number of test cases. The description of test cases follows.
The only line of each test case contains the integer ().
Output one integer — the minimum possible obtained value.
In the image below you can see the example solutions for the first two test cases. Chosen days off are shown in purple. Working segments are underlined in green.
In test case , the only options for days off are days , , and (because and are next to day ). So the only way to place them without selecting neighboring days is to choose days and .
No comments:
Post a Comment