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 1731. Dill

idea
Posted by dustbite 8 Nov 2016 09:43
there are n * m possible sums. to find a solution, we can try to create such vectors such that all n * m sums are different.
Suppose the 1st vector is 1 2 3 ... n

Then the first element of next vector is taken to be n + 1(we require all unique).
Now we need to find the next element while making all n*p sums different, where p is the size of the 2nd vector.

n+1
1 2 3 ... n

initially all sums(n+2 to 2n+1) are distinct. Now we need to add new element such that
smallest possible new sum is greater than the previous sum
i.e. if new element is p
p+1>2n+1
or p >= 2n + 1
in general p+1>prev+n
p>=prev+n