fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10.  
  11. static long arrayManipulation(int n, int[][] q) {
  12.  
  13. int[][]data = new int[2*q.length][2];
  14. int index = 0;
  15. for(int i = 0; i < q.length; i++){
  16. data[index][0] = q[i][0];
  17. data[index][1] = q[i][2];
  18. index++;
  19. data[index][0] = q[i][1];
  20. data[index][1] = -q[i][2];
  21. index++;
  22. }
  23. Arrays.sort(data, (a, b) -> {
  24. if(a[0] != b[0]){
  25. return Integer.compare(a[0], b[0]);
  26. }
  27. return Integer.compare(b[1], a[1]);
  28.  
  29. });
  30. long result = 0;
  31. long sum = 0;
  32. for(int[]a : data){
  33. // System.out.println(Arrays.toString(a));
  34. sum += (long)a[1];
  35. result = Long.max(result, sum);
  36. }
  37. return result;
  38. }
  39. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
spoj: The program compiled successfully, but main class was not found.
      Main class should contain method: public static void main (String[] args).
stdout
Standard output is empty