package com.supermars.practice;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class 贪心法区间选点问题 {
static Ac2 ac[] = new Ac2[1 << 10];
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int case_ = 1;
while (cin.hasNext()) {
int n = cin.nextInt();
for (int i = 0; i < n; i++) {
int a = cin.nextInt();
int b = cin.nextInt();
if (a > b) {
int t = a;
a = b;
b = t;
}
ac[i] = new Ac2(a, b);
}
int cnt = 1;
Arrays.sort(ac, 0, n, new cmp2());
int ok = ac[0].end;
for (int i = 1; i < n; i++) {
if(ok<ac[i].begin){
cn
ACMjava经典贪心区间问题,区间选点,不相交区间,区间覆盖
最新推荐文章于 2022-10-26 19:52:19 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)