A1327 | [COCI-2015_2016-contest7]#4 PROKLETNIK
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Young Luka is about to enter a house with the evil witch Marica inside. As soon as he enters the house, she asks him questions about her array of N numbers. Luka fearfully asks for a clarification of the questions. Marica explains to him that each query consists of two integers L and R which represent the positions of a contiguous sub-array in her array.
It is Luka’s task to answer for each query what the longest contiguous sub-array of that contiguous sub-array (it can be the entire sub-array) having the property of being magical. An array is called magical if all the values are between the values of the first and last number in that array. For example, [1 3 1 2 4] is magical, the same as [4 1 1 2 1], whereas [3 3 4 1] is not magical.
It is Luka’s task to answer for each query what the longest contiguous sub-array of that contiguous sub-array (it can be the entire sub-array) having the property of being magical. An array is called magical if all the values are between the values of the first and last number in that array. For example, [1 3 1 2 4] is magical, the same as [4 1 1 2 1], whereas [3 3 4 1] is not magical.
输入格式
The first line of input contains the integer N (1 6 N 6 500 000), the number of numbers in the array.
The second line contains N integers ai (1 6 ai 6 109 ).
The third line contains the integer Q (1 6 Q 6 500 000), the number of queries.
Each of the following Q lines contains two integers, L and R (1 6 L 6 R 6 N), representing the sub-array from the query.
The second line contains N integers ai (1 6 ai 6 109 ).
The third line contains the integer Q (1 6 Q 6 500 000), the number of queries.
Each of the following Q lines contains two integers, L and R (1 6 L 6 R 6 N), representing the sub-array from the query.
输出格式
The i th line of output must contain a single integer – the answer to the i th query.
输入输出样例
输入 #1
5 5 4 3 3 2 3 1 2 1 1 2 4
输出 #1
2 1 3
输入 #2
6 6 6 5 1 6 2 3 4 5 4 6 1 4
输出 #2
2 2 4
In test cases worth 50% of total points, it will hold N, Q 6 30 000.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted