Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 307 Weeks Ago, 6 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 15 Sep 2017 My Price 8.00

array of N integers

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 and Aa > Ab.

Input

First line consists of N and K in single line. Next line contains N space separated integers denoting array A.

 

Output

Print the required answer in one line.

Constraints

Should contain all the constraints on the input data that you may have. Format it like:

  • 1 = N = 105
  • 0 = Ai = 109
  • 0 = K = N*(N-1)/2

 

Example

Input 1: 4 1 1 2 4 0 Input 2: 2 0 1 2 Output 1: 3 Output 2: 3

 

Explanation

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.

Note: Large input files. Use scanf/printf instead of cin/coun

Answers

(5)
Status NEW Posted 15 Sep 2017 11:09 PM My Price 8.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)