codeforces-scrape

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

1840C.md (2323B)


      1 Source: https://codeforces.com/problemset/problem/1840/C
      2 
      3 C. Ski Resort
      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 Dima Vatrushin is a math teacher at school. He was sent on vacation for $n$ days for his good work. Dima has long dreamed of going to a ski resort, so he wants to allocate several consecutive days and go skiing. Since the vacation requires careful preparation, he will only go for at least $k$ days.
     22 
     23 You are given an array $a$ containing the weather forecast at the resort. That is, on the $i$-th day, the temperature will be $a_i$ degrees.
     24 
     25 Dima was born in Siberia, so he can go on vacation only if the temperature does not rise above $q$ degrees throughout the vacation.
     26 
     27 Unfortunately, Dima was so absorbed in abstract algebra that he forgot how to count. He asks you to help him and count the number of ways to choose vacation dates at the resort.
     28 
     29 Input
     30 
     31 The first line of the input contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.
     32 
     33 Then follow the descriptions of the test cases.
     34 
     35 The first line of each test case contains three integers $n$, $k$, $q$ ($1 \le n \le 2 \cdot 10^5$, $1 \le k \le n$, $-10^9 \le q \le 10^9$) — the length of the array $a$, the minimum number of days at the resort, and the maximum comfortable temperature for Dima.
     36 
     37 The second line of each test case contains $n$ integers $a_1, a_2, a_3, \dots, a_n$ ($-10^9 \le a_i \le 10^9$) — the temperature at the ski resort.
     38 
     39 The sum of all $n$ values over all test cases does not exceed $2 \cdot 10^5$.
     40 
     41 Output
     42 
     43 Output $t$ integers, each of which is the answer to the corresponding test case — the number of ways for Dima to choose vacation dates at the resort.
     44 
     45 Example
     46 
     47 Input
     48 
     49 ```
     50 7
     51 
     52 3 1 15
     53 
     54 -5 0 -10
     55 
     56 5 3 -33
     57 
     58 8 12 9 0 5
     59 
     60 4 3 12
     61 
     62 12 12 10 15
     63 
     64 4 1 -5
     65 
     66 0 -1 2 5
     67 
     68 5 5 0
     69 
     70 3 -1 4 -5 -3
     71 
     72 1 1 5
     73 
     74 5
     75 
     76 6 1 3
     77 
     78 0 3 -2 5 -4 -4
     79 ```
     80 
     81 Output
     82 
     83 ```
     84 6
     85 0
     86 1
     87 0
     88 0
     89 1
     90 9
     91 ```
     92 
     93 Note
     94 
     95 In the first test case of the example, Dima can go on any day, so the suitable dates for him are [1], [2], [3], [1, 2], [2, 3], [1, 2, 3].
     96 
     97 In the second and fourth test cases of the example, Dima cannot go on any day due to the high temperature, so there are no suitable dates.
     98 
     99 In the third test case of the example, Dima can only go on the dates [1, 2, 3].