Submit a solution
The challenge is finished.

Challenge Overview

MATCH LEADERBOARD:  Please refer to this leaderboard for the match. 
The match leaderboard on the page is currently not updating itself and has some issues. We are working on it to get it resolved asap. Thanks for your patience!

New Marathon Match Platform Guide -
The guide contains help sections on the following topics:

  1. Languages Supported

  2. Submission Format

  3. Virtual Machine/ Docker Container OS Version

  4. Compiler Versions

  5. Setup Local Environment Similar to Tester Machine

  6. Download/Access your Previous Submissions

  7. Example Test Case Scores and Run Time

  8. Notification Emails

  9. Time Limit Exceed


Several individuals, of varying heights, are performing a show. The show requires performers to change positions so that their heights match, as close as possible, desired patterns. A full show requires them to move into several different arrangements.

As the show director wants everything to look as good as possible, it is desired that the heights of the performers at each step are as close as reasonably possible to the prescribed arrangement. However, since the performers are human, it is also necessary to, as much as possible, minimize how much the performers have to move around in between different arrangements. These two factors together determine your score on each test case, and it is up to you to balance the importance of both as you see fit.

Test Case Generation

The number of performers, N, is chosen between 10 and 100.
The number of arrangements, X, is chosen between 2 and 20.
The maximum possible height of a performer, M, is chosen between 10 and 1000.
The height of each performer is chosen between 1 and M.
The desired height at each of the N locations in each of the X arrangements, is also chosen between 1 and M.


heights[] contains the height of each performer, in the order they initially appear on stage. (N can be determined based upon the length of the array)

arrangements[] contains the desired performer height for each of the X arrangements. Elements 0...N-1 are the first arrangement, N...2N-1 are the second, and so on.

The return value should indicate the index of the performer to stand at each position, for each of the X arrangements. That is to say, elements 0...N-1 of the return refer to the first arrangement, elements N...2N-1 are the second arrangement, and so on.


For each arrangement, the distance each perform needs to move to get in position, dist, is calculated. For each position, the difference between the desired height and actual performer height, err, is calculated.

The score for a test case is then calculated as SUM(dist) + SQRT(SUM(err^2))

Any test case in which your code returns an invalid value, will score a -1. Any test case in which your code exceeds the time limit of 10s, you will score a -2.

Your overall score will be calculated as the sum of BEST/YOURS, for each test case on which you got a positive score, where BEST is the lowest (positive) score anyone received for that test case, and YOURS is your score on that test case. The relative scores are summed, and scaled to 100.0 to give your overall score.


Offline Tester

An offline tester is available for use in this contest. (It is identical to what is used by the system to score and run submissions.)

Sample submissions, which are suitable for submitting, are available here. Note that these also include the required I/O calls which are needed not only for the submission, but also work with the offline tester.

To run the tester with your solution, you should run:
java -jar Tester.jar -exec "<command>" -seed <seed>

Here, <command> is the command to execute your program, and <seed> is seed for test case generation. If your compiled solution is an executable file, the command will be the full path to it, for example, "C:\TopCoder\solution.exe" or "~/topcoder/solution". In case your compiled solution is to be run with the help of an interpreter, for example, if you program in Java, the command will be something like "java -cp C:\TopCoder Solution".

Finally, you can print any debug information of your solution to standard error, and it will be forwarded to the standard out of the tester.