You are given a sequence of integers A1,A2,…,ANA1,A2,…,AN and an integer KK. Find the number of contiguous subsequences AL,AL+1,…,ARAL,AL+1,…,AR such that R−L+1≥KR−L+1≥K and the KK-th element of the subsequence (AL+K−1AL+K−1) is equal to the maximum of all elements of the entire sequence.- You are given a sequence of integers A1,A2,…,ANA1,A2,…,AN and an integer KK. Find the number of contiguous subsequences AL,AL+1,…,ARAL,AL+1,…,AR such that R−L+1≥KR−L+1≥K and the KK-th element of the subsequence (AL+K−1AL+K−1) is equal to the maximum of all elements of the entire sequence.

You are given a sequence of integers A1,A2,,ANA1,A2,…,AN and an integer KK. Find the number of contiguous subsequences AL,AL+1,,ARAL,AL+1,…,AR such that RL+1KR−L+1≥K and the KK-th element of the subsequence (AL+K1AL+K−1) is equal to the maximum of all elements of the entire sequence.

For each test case, print a single line containing one integer — the number of contiguous subsequences satisfying the given conditions.

Example case 1: (3,4,5)(3,4,5) is the only contiguous subsequence such that its 33-rd element is equal to the maximum of the whole sequence (which is 55).

5★janmansh

24-08-2021

0.5 secs

50000 Bytes

CPP14, C, JAVA, PYTH 3.6, CPP17, PYTH, PYP3, CS2, ADA, PYPY, TEXT, PAS fpc, NODEJS, RUBY, PHP, GO, HASK, TCL, PERL, SCALA, LUA, kotlin, BASH, JS, LISP sbcl, rust, PAS gpc, BF, CLOJ, R, D, CAML, FORT, ASM, swift, FS, WSPC, LISP clisp, SQL, SCM guile, PERL6, ERL, CLPS, ICK, NICE, PRLG, ICON, COB, SCM chicken, PIKE, SCM qobi, ST, SQLQ, NEM

You are given a sequence of integers A1,A2,…,ANA1,A2,…,AN and an integer KK. Find the number of contiguous subsequences AL,AL+1,…,ARAL,AL+1,…,AR such that R−L+1≥KR−L+1≥K and the KK-th element of the subsequence (AL+K−1AL+K−1) is equal to the maximum of all elements of the entire sequence.

Leave a Comment

Your email address will not be published. Required fields are marked *

fastnewsxpress