For this Question: Tono is on her mission to spread happiness everywhere. She has N close friends. She wants to make them stand in a line. She knows the happiness of the i<sup>th</sup> friend will be A[i] if the friend is standing among the first C[i] people in the line, else it would be B[i].

Find the maximum happiness that Tono can have in the line if she can arrange her friends in any order.The first line of the input contains an integer N.
The next N lines of the input contain three integers C[i], A[i], and B[i] denoting the parameters for the i<sup>th</sup> friend.

Constraints
1 <= N <= 100000
1 <= C[i] <= N
1 <= L[i], R[i] <= 10<sup>9</sup>Output the maximum happiness that Tono can achieve in the line.Sample Input
3
2 93 78
1 71 59
3 57 96

Sample Output
221

Explanation
The optimal order is [2, 1, 3]. 
The happiness of friend 1 = 93 (among the first 2 people), friend 2 = 71 (among the first 1 people), and friend 3 = 57 (among the first 3 people).

Sample Input
2
1 5 10
2 15 5

Sample Output
25, I have written this Solution Code: import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));


            int n = sc.nextInt();
            Map<Integer, ArrayList<Camel>> map = new HashMap<>();
            for (int i = 0; i < n; i++) map.put(i, new ArrayList<>());
            Camel[] c = new Camel[n];
            long base = 0;
            for (int i = 0; i < n; i++) {
                int split = sc.nextInt();
                long l = sc.nextInt();
                long r = sc.nextInt();
                c[i] = new Camel(l - r, split - 1);
                map.get(c[i].split).add(c[i]);
                base += Math.min(l, r);
            }
            Arrays.sort(c, Comparator.comparingInt(a -> a.split));
            PriorityQueue<Long> pq = new PriorityQueue<>();
            for (int i = 0; i < n; i++) {
                for (Camel camel : map.get(i)) {
                    if (camel.dif < 0) continue;
                    pq.add(camel.dif);
                    base += camel.dif;
                }
                while (pq.size() > i + 1) {
                    long bestRemove = pq.poll();
                    base -= bestRemove;
                }
            }
            pq = new PriorityQueue<>();
            for (int i = n - 1; i >= 0; i--) {
                for (Camel camel : map.get(i)) {
                    if (camel.dif >= 0) continue;
                    pq.add(-camel.dif);
                    base += -camel.dif;
                }
                while (pq.size() > n - i - 1) {
                    long bestRemove = pq.poll();
                    base -= bestRemove;
                }
            }
            out.println(base);


        out.close();
    }

    static class Camel {
        long dif; int split;
        Camel(long dif, int split) {
            this.dif = dif; this.split =split;
        }
    }



    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}, In this Programming Language: Java, Now tell me if this Code is compilable or not?