401940: GYM100589 H Count Subarrays
Memory Limit:512 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
H. Count Subarraystime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output
Given an array of N integers A1, A2 ... AN and an integer K, count number of subarrays of A such that number of inversions in those subarrays is at least K.
Inversions in a subarray Ai, Ai + 1,..., Aj is defined as number of pairs (a, b) such that i ≤ a < b ≤ j and Aa > Ab.
InputFirst line consists of N and K in single line. Next line contains N space separated integers denoting array A.
OutputPrint the required answer in one line.
Constraints
- 1 ≤ N ≤ 105
- 0 ≤ Ai ≤ 109
- 0 ≤ K ≤ N * (N - 1) / 2
4 1Output
1 2 4 0
3Input
2 0Output
1 2
3Note
Let’s denote by A[i, j] the subarray Ai, Ai + 1 ... Aj.
Example 1. A[1, 4], A[2, 4], A[3, 4] have at least 1 inversion.
Example 2. All subarrays are valid.