Problem link My Submissions here My logic
Eg Let there be 5 buildings of height one. I had already defined an array "height[1000001]={0}" to store number of buildings of a particular height. So, it will store 5 for 1. Now, say our array is like 1 1 1 1 1 I can pair 1 at I=0 with 1 at I=1,2,3,4. Similarly I can pair 1 at I=1 with 1 at 1=0,2,3,4. So I derive the formula Number of Pairs = n(n1) (via mathematical induction) But its giving me WA. Can someone help? :) asked 18 Mar '17, 00:12

The question has been closed for the following reason "The question is answered, right answer was accepted" by vijju123 18 Mar '17, 11:27
i think you should change the data type to long long and the use the above method.. answered 18 Mar '17, 00:32
which "Above method" ? The method which I used or the method linked by @monalshadi?
(18 Mar '17, 00:39)
the method used by you..n*(n1)
(18 Mar '17, 11:15)

Hello @vijju123 I too faced the same problem My solution link :My solution I thought maybe I was doing something wrong then I went on to check some AC and I found this in one of the AC's another AC @admin I think there might be something wrong while checking the test cases. Please look into this. answered 18 Mar '17, 00:20
That answer used maps. I am ineligible to comment since I don't know that concept. If you feel that there is something wrong, then mail it at bugs@codechef.com and they'd confirm the issue. :)
(18 Mar '17, 00:35)
1
It doesn't matter, map is just another way to store data. Main thing is about the logic or algorithm. I guess I did the same mistake too with overflow, I used long int in place of long long int. Thanks for pointing out this post :)
(18 Mar '17, 00:43)
If it proved helpful to you, I am most glad dear :)
(18 Mar '17, 00:44)

Thanks to all of you, I got correct answer. Yes, the problem was overflow, I should be more careful next time. Thanks again! :) answered 18 Mar '17, 11:26

No it sets the entire array to zero
That was initialisation done once. Please see my code to get a clearer picture :)