SHARE
TWEET

Untitled

a guest Dec 8th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int N = scanner.nextInt();
  8.         int[][] arr = new int[N][2];
  9.  
  10.         for (int i = 0; i < N; i ++) {
  11.             arr[i][0] = scanner.nextInt();
  12.             arr[i][1] = scanner.nextInt();
  13.         }
  14.  
  15.         int mv = 0;
  16.  
  17.         for (int i = 0; i < N; i ++) {
  18.             int[] cov = new int[1001];
  19.  
  20.             for (int j = 0; j < N; j ++) {
  21.                 if (j == i)
  22.                     continue;
  23.                 for (int k = arr[j][0]; k < arr[j][1]; k ++)
  24.                     cov[k] = 1;
  25.             }
  26.  
  27.             int cur = 0;
  28.             for (int j = 0; j <= 1000; j ++) {
  29.                 cur += cov[j];
  30.             }
  31.  
  32.             mv = Math.max(mv, cur);
  33.         }
  34.  
  35.         System.out.println(mv);
  36.     }
  37.  
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top