Maximum Residue
Submit solution
Points:
12 (partial)
Time limit:
1.0s
Python
3.0s
Memory limit:
256M
Author:
Problem type
Bobby is bored. But Bobby has an idea. He will invent a game to reduce his boredom.
He just so happens to have a list of \(N\) integers. The game he invents is so: he chooses two values in the list \(a_i\) and \(a_j\) (\(1 \le i,j \le N\)) where \(a_i \ge a_j\). He then calculates the residue of \(a_i\) mod \(a_j\). He wants to find \(a_i\) and \(a_j\) such that he maximizes the residue.
He then invites you to play. Can you beat the game?
Input Specification
The first line has the integer \(N\): the number of integers in his list. The second line contains \(N\) space-separated integers \(a_1...a_N\).
Output Specification
Print the maximum possible residue.
Constraints
\(1 \le N, a_i \le 10^5\)
Sample Input
4
4 2 7 2
Sample Output
3
Comments
Can someone please tell me the actual time complexity of my code. thanks.
Ok I'm pretty sure your testcases are very weak
weak info