This page is still under construction.

Parts of this page are still being built. What you see may change.

Cinema Academy

Interview

Time limit1sMemory limit1024 MB

Summary
Choose two different films to win best directing and best screenplay so that the total delight, where each film contributes one of three values depending on its outcome, is maximized.
Level

Medium5 of 10

Topics
Greedy, Array, Implementation, Sorting
Solved
No attempts yet

Problem

The nn best films of 2014 reached the final of the Cinema Academy contest. The contest awards films in two categories: best directing and best screenplay. By the rules, exactly one film must be awarded in each category, and the films awarded in the two categories must be different.

Through numerous surveys of viewers and film critics, data was collected showing the level of delight that a win by each film in each category would cause. Thorough journalists did not stop there and also determined the level of delight if a given film wins in neither category.

Write a program that uses the survey results to determine the greatest total level of delight that can be achieved by choosing the films to award in the given categories.

Input

The first line of the input file contains an integer nn, the number of films competing in the final of the Cinema Academy contest. The next nn lines contain three integers each, aia_i, bib_i, cic_i: the level of delight if the ii-th film wins in neither category, the level of delight if this film wins best directing, and the level of delight if this film wins best screenplay.

Output

The first line of the output file must contain a single number: the greatest possible total level of delight. The second line must contain two integers: the numbers of the winning films in best directing and best screenplay, respectively. Films are numbered with the natural numbers from 11 to nn. If there are several optimal ways to choose the awarded films, you may output any of them.

Constraints

  • 2≤n⩽1052 \le n \leqslant 10^5
  • 1≤ai,bi,ci⩽1091 \le a_i, b_i, c_i \leqslant 10^9

Hint

In the example given, the greatest total level of delight is 3+5+9=173 + 5 + 9 = 17.

Examples1

  1. Example 1

    Input
    3
    3 6 9
    1 5 7
    1 3 9
    
    Expected output
    17
    2 3