Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int N = scanner.nextInt();
- int[][] arr = new int[N][2];
- for (int i = 0; i < N; i ++) {
- arr[i][0] = scanner.nextInt();
- arr[i][1] = scanner.nextInt();
- }
- int mv = 0;
- for (int i = 0; i < N; i ++) {
- int[] cov = new int[1001];
- for (int j = 0; j < N; j ++) {
- if (j == i)
- continue;
- for (int k = arr[j][0]; k < arr[j][1]; k ++)
- cov[k] = 1;
- }
- int cur = 0;
- for (int j = 0; j <= 1000; j ++) {
- cur += cov[j];
- }
- mv = Math.max(mv, cur);
- }
- System.out.println(mv);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement