欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1735A.Working Week
Working Week
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.
Input
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
For each test case, output one integer — the maximum possible obtained value.
Note
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 . Thus, , and the answer .

For test case , one possible way to choose days off is shown. The working segments have the lengths of , , and days. So the minimum difference is $1 = \min(1, 3, 2) = \min(|2 - 1|, |1 - 4|, |4 - 2|)$. It can be shown that there is no way to make it larger.

Samples
3
6
10
1033
0
1
342
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |