You are given a sequence of integersand an integer . Find the number of contiguous subsequences such that and the -th element of the subsequence ( ) 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:is the only contiguous subsequence such that its -rd element is equal to the maximum of the whole sequence (which is ).
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.