9 / 9
Jul 2022

How to solve this problem? Are we supposed to solve it by greedy?

  • created

    Nov '06
  • last reply

    Jul '22
  • 8

    replies

  • 661

    views

  • 8

    users

it wud be obvious that it's greedy if u what was "rearrangement inequality" wink

29 days later

I remember "rearrengement inequality" from my math classes: we learnt something about spaces, metrics and so on.

This problem doesn't require anything sophisticated. Fact: you'll get the highest possible product if you multiply the highest number in the first list by the highest number in the second list.

10 days later

Well, thanks to [color=red]kawigi [/color] for so many good problems on Sphere, but this one is purely mathematical, coding part is sorting only. Once we started to programming, let's do programming smile
We would like to see such problems as "Exchange Operations" here, and 851 - "Maze" on UVa.

2 years later

Ok, I have solved the problem by sorting. But can someone explain the idea behind this?

Thanks.

12 years later

Anyone please explain, I used Arrays.sort() in java to sort the array. When I used merge sort, I got TLE, where as when I used merge sort the code got accepted. How it happens? Time complexity of merge sort is always <= timecomplexity of quick sort, right?