codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1199A.md (2066B)


      1 Source: https://codeforces.com/problemset/problem/1199/A
      2 
      3 A. City Day
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 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 \lt a_j$ should hold for all $d - x \le j \lt d$ and $d \lt j \le d + y$. Citizens only watch the weather during summer, so we only consider such $j$ that $1 \le j \le n$.
     24 
     25 Help mayor find the earliest not-so-rainy day of summer.
     26 
     27 Input
     28 
     29 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.
     30 
     31 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.
     32 
     33 Output
     34 
     35 Print a single integer — the index of the earliest not-so-rainy day of summer. We can show that the answer always exists.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 10 2 2
     43 10 9 6 7 8 3 2 1 4 5
     44 ```
     45 
     46 Output
     47 
     48 ```
     49 3
     50 ```
     51 
     52 Input
     53 
     54 ```
     55 10 2 3
     56 10 9 6 7 8 3 2 1 4 5
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 8
     63 ```
     64 
     65 Input
     66 
     67 ```
     68 5 5 5
     69 100000 10000 1000 100 10
     70 ```
     71 
     72 Output
     73 
     74 ```
     75 5
     76 ```
     77 
     78 Note
     79 
     80 In the first example days $3$ and $8$ are not-so-rainy. The $3$-rd day is earlier.
     81 
     82 In the second example day $3$ is not not-so-rainy, because $3 + y = 6$ and $a_3 \gt 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.