Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- int n = s.nextInt();
- for(int i = 1; i <= n; i++) {
- int a = s.nextInt();
- ArrayList<Integer> heights = new ArrayList<Integer>();
- for(int h = 0; h < a; h++) {
- int d = s.nextInt();
- heights.add(s.nextInt());
- }
- int l = 0;
- for(int e = 0; e < heights.size() - 1; e++) {
- int c = 0;
- for(int v = e + 1; v < heights.size(); v++) {
- if(heights.get(v) >= heights.get(v - 1)) {
- System.out.println(e + (heights.get(v)));
- c+= (heights.get(v) - heights.get(v - 1));
- }
- }
- if(c > l) l = c;
- }
- System.out.println(i + " " + l);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement