A12852 | City Day
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
For years, the Day of city N was held in the most rainy day of summer. New mayor decided to break this tradition and select a not-so-rainy day for the celebration. The mayor knows the weather forecast for the $n$ days of summer. On the $i$ -th day, $a_i$ millimeters of rain will fall. All values $a_i$ are distinct.
The mayor knows that citizens will watch the weather $x$ days before the celebration and $y$ days after. Because of that, he says that a day $d$ is not-so-rainy if $a_d$ is smaller than rain amounts at each of $x$ days before day $d$ and and each of $y$ days after day $d$ . In other words, $a_d < a_j$ should hold for all $d - x \le j < d$ and $d < j \le d + y$ . Citizens only watch the weather during summer, so we only consider such $j$ that $1 \le j \le n$ .
Help mayor find the earliest not-so-rainy day of summer.
The mayor knows that citizens will watch the weather $x$ days before the celebration and $y$ days after. Because of that, he says that a day $d$ is not-so-rainy if $a_d$ is smaller than rain amounts at each of $x$ days before day $d$ and and each of $y$ days after day $d$ . In other words, $a_d < a_j$ should hold for all $d - x \le j < d$ and $d < j \le d + y$ . Citizens only watch the weather during summer, so we only consider such $j$ that $1 \le j \le n$ .
Help mayor find the earliest not-so-rainy day of summer.
输入格式
The first line contains three integers $n$ , $x$ and $y$ ( $1 \le n \le 100\,000$ , $0 \le x, y \le 7$ ) — the number of days in summer, the number of days citizens watch the weather before the celebration and the number of days they do that after.
The second line contains $n$ distinct integers $a_1$ , $a_2$ , ..., $a_n$ ( $1 \le a_i \le 10^9$ ), where $a_i$ denotes the rain amount on the $i$ -th day.
The second line contains $n$ distinct integers $a_1$ , $a_2$ , ..., $a_n$ ( $1 \le a_i \le 10^9$ ), where $a_i$ denotes the rain amount on the $i$ -th day.
输出格式
Print a single integer — the index of the earliest not-so-rainy day of summer. We can show that the answer always exists.
输入输出样例
输入 #1
10 2 2 10 9 6 7 8 3 2 1 4 5
输出 #1
3
输入 #2
10 2 3 10 9 6 7 8 3 2 1 4 5
输出 #2
8
输入 #3
5 5 5 100000 10000 1000 100 10
输出 #3
5
In the first example days $3$ and $8$ are not-so-rainy. The $3$ -rd day is earlier.
In the second example day $3$ is not not-so-rainy, because $3 + y = 6$ and $a_3 > a_6$ . Thus, day $8$ is the answer. Note that $8 + y = 11$ , but we don't consider day $11$ , because it is not summer.
In the second example day $3$ is not not-so-rainy, because $3 + y = 6$ and $a_3 > a_6$ . Thus, day $8$ is the answer. Note that $8 + y = 11$ , but we don't consider day $11$ , because it is not summer.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted