ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1880. Psych Up's Eigenvalues

Did the problem without using binary search. However it takes 0.109 seconds.
Posted by bluestar 4 Mar 2015 18:53
The main method I followed was to first compare two of the arrays and extract the similar values in another array. I then compared that array with the third array, and updated the counter each time there was a match in eigenvalues. This method avoids comparing all the arrays together, and hence takes up less time. So in essence number of operations reduces to O(2*N^2) instead of O(N^3). However, more sophisticated algorithms like binary search are more effective. But still I include this method for people like myself, who are new to algorithms. Hope it helps someone.
Re: Did the problem without using binary search. However it takes 0.109 seconds.
Posted by Zteeks 20 Dec 2016 22:28
Thank you! Did as you said and get Accepted))
0.046 seconds (FreePascal)