Submit | All submissions | Best solutions | Back to list |
SAS001 - Apoorv and Maximum Inversion |
Apoorv has an array of n integers. Inversion count of an array is defined by number of pair of indices(i,j) such that i
Constraints :
1<=n<=500000
-1000000000<=arr[i]<=1000000000
1<=p<=n
Input
First line contains two integers n and p.
Next line contains n space separated integers denoting the elements of the array.
Output
Output two space separated integers first integer should be the starting index (1-based indexing) of the subarray and next integer would be the count of inversions in that subarray.In case there is a tie in maximum inversion count print the smallest starting index among the subarrays having maximum inversion count.
Example
Input: 10 5 15 51 44 44 76 50 29 88 48 50 Output: 5 6
Added by: | sas1905 |
Date: | 2017-08-11 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | Own |
hide comments
|
|||||
2018-06-05 19:10:50
Nice problem :) |
|||||
2018-03-27 08:24:01
Segment tree :D |
|||||
2018-03-17 11:48:04
Nice question! BIT+sliding window :) |
|||||
2018-03-16 19:59:52
Nice problem :) sas1905 _/\_ |
|||||
2017-12-31 11:51:09
My 175 on spoj :) |
|||||
2017-10-25 18:17:36
Segment tree + sliding window... try the problem "Inversion Count" in SPOJ before solving this.. that will be of great help ..HAPPY CODING! :D |
|||||
2017-08-13 18:53:16
sas pro! Nice problem.. :) |
|||||
2017-08-12 18:24:08
Sas pro!! _/\_ Good one :) |
|||||
2017-08-12 13:40:09
Nice question! Sas pro! _/\_ map -> TLE unordered_map -> AC |
|||||
2017-08-12 05:05:55
Nice problem :) |