#K69007. Candy Weighted Sum Maximization

    ID: 32990 Type: Default 1000ms 256MiB

Candy Weighted Sum Maximization

Candy Weighted Sum Maximization

You are given ( n ) types of candies. Each candy type ( i ) has a size ( s_i ) and a sweetness ( w_i ). The goal is to arrange the candies in a permutation so that the total weighted sum is maximized, where the weight for a candy is simply the sum of its size and sweetness, i.e., ( s_i + w_i ). In other words, you need to sort the candies in descending order based on ( s_i + w_i ). If two candies have the same sum, maintain the natural order (i.e., the candy with the smaller index comes first).

Input/Output Note: The input is read from standard input (stdin) and the output is written to standard output (stdout).

inputFormat

The first line contains an integer ( n ) representing the number of candy types. The second line contains ( n ) space-separated integers representing the sizes ( s_1, s_2, \ldots, s_n ). The third line contains ( n ) space-separated integers representing the sweetnesses ( w_1, w_2, \ldots, w_n ).

outputFormat

Output a single line with ( n ) integers — the permutation of candy indices that maximizes the total weighted sum. The indices should be separated by a single space.## sample

3
2 8 5
3 6 4
2 3 1