Here is the problem:

SIMPLE LCM

Here is my solution:

Solution

Can anyone tell me what’s wrong with my solution. I sorted the input and looked for adjacent values to get the maximum LCM pair.

Here is the problem:

SIMPLE LCM

Here is my solution:

Solution

Can anyone tell me what’s wrong with my solution. I sorted the input and looked for adjacent values to get the maximum LCM pair.

take this simple input

3

5 6 9

result should be : 45 (by pair 5 and 9)

your code output : 30 (by pair 5 and 6)

1 Like

Thanks for the input. I will work on the logic again!

Can you please tell why this solution got accepted which is almost in the same way as that of mine.

I was searching the solution after the contest got over and I found this.

Random Solution from Successful Submissions

this solution also fails on the test case I mentioned earlier , I have no idea how this solution could pass.

My be the test data is weak.

1 Like

Thanks for the help. If the test data is weak, it should accept mine also right? Correct me if I am wrong.

the good thing is test data has been updated.

so if the random solution you posted in one of your comments (which was getting AC and has same solution as yours) that will result into WA too if you submit that now (I have just tested it).

here is the exact same problem : Problem - F - Codeforces

read it’s editorial for solution

1 Like

Thanks for the help!

you’re welcome man

As its Checking only Adjacent pairs to have Maximum Pair. Maximum lcm pair in a series is not necessary to be present in Adjacent Values

Got it! Thanks for the help