A1235 | [COCI-2011_2012-contest4]#6 ZIMA
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
In the old times, when dragons ruled the land, air temperature never fell below zero degrees. But after dragons left, nice and warm times went with them.
We say that day is a winter day when average temperature for that day is below zero. We say that T consecutive winter days form a winter period of length T.
There are some people that annoy everyone by rambling on about some winter that is coming. So a law had to be made, stating that you are allowed to say that winter is coming at most 2T days before a winter period of length T. Exception to this is only the winter period with the longest length, that can be announced at most 3T days before it begins. During some winter period, you can’t say that this period is coming, since it’s already here, but you can announce future winter periods according to the rules above. If there are more than one winter periods with the longest length, then only one is chosen and 3T days rule is applied only to that period.
Knowing expected temperatures for some time period, find out the maximum number of days during which it is allowed to say that winter is coming.
We say that day is a winter day when average temperature for that day is below zero. We say that T consecutive winter days form a winter period of length T.
There are some people that annoy everyone by rambling on about some winter that is coming. So a law had to be made, stating that you are allowed to say that winter is coming at most 2T days before a winter period of length T. Exception to this is only the winter period with the longest length, that can be announced at most 3T days before it begins. During some winter period, you can’t say that this period is coming, since it’s already here, but you can announce future winter periods according to the rules above. If there are more than one winter periods with the longest length, then only one is chosen and 3T days rule is applied only to that period.
Knowing expected temperatures for some time period, find out the maximum number of days during which it is allowed to say that winter is coming.
输入格式
The first line of input contains the integer N (1 ≤ N ≤ 100 000), length of the overall time period we are considering. The following line contains N integers, temperatures of consecutive days in considered period. Absolute values of these integers won’t exceed 10
0.
0.
输出格式
The first and only line of output should contain the maximum number of days during which it is allowed to announce the winter is coming.
输入输出样例
输入 #1
8 1 -1 4 3 8 -2 3 -3
输出 #1
6
输入 #2
15 1 2 -1 2 3 4 5 6 1 4 8 3 -1 -2 1
输出 #2
8
In test cases worth 40% of total points, there will be only one winter period with the longest length.
First sample description: There are three winter periods of length one. In order to obtain the
requested maximum, best thing to do is to choose the second one to apply the 3T days rule, and
starting announcing it three days before it arrives.
First sample description: There are three winter periods of length one. In order to obtain the
requested maximum, best thing to do is to choose the second one to apply the 3T days rule, and
starting announcing it three days before it arrives.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted