Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3.  
  4. class Main {
  5.     public static void main(String[] args) {
  6.         Scanner s = new Scanner(System.in);
  7.         int n = s.nextInt();
  8.         for(int i = 1; i <= n; i++) {
  9.             int a = s.nextInt();
  10.             ArrayList<Integer> heights = new ArrayList<Integer>();
  11.             for(int h = 0; h < a; h++) {
  12.                 int d = s.nextInt();
  13.                 heights.add(s.nextInt());
  14.             }
  15.             int l = 0;
  16.             for(int e = 0; e < heights.size() - 1; e++) {
  17.                 int c = 0;
  18.                 for(int v = e + 1; v < heights.size(); v++) {
  19.                     if(heights.get(v) >= heights.get(v - 1)) {
  20.                         System.out.println(e + (heights.get(v)));
  21.                         c+= (heights.get(v) - heights.get(v - 1));
  22.                     }
  23.                 }
  24.                 if(c > l) l = c;
  25.             }
  26.             System.out.println(i + " " + l);
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement