矩形嵌套
KB
- 描述
- 有n个矩形,每个矩形可以用a,b来描述,表示长和宽。矩形X(a,b)可以嵌套在矩形Y(c,d)中当且仅当 a
-
- 输入
- 第一行是一个正正数N(0
每组测试数据的第一行是一个正正数n,表示该组测试数据中含有矩形的个数(n<=1000)
随后的n行,每行有两个数a,b(0<100),表示矩形的长和宽 - 输出
- 每组测试数据都输出一个数,表示最多符合条件的矩形数目,每组输出占一行
- 样例输入
-
1
-
10
-
1 2
-
2 4 -
5 8 -
6 10 -
7 9
-
3 1 -
5 8 -
12 10 -
9 7 -
2 2 - 样例输出
-
5
- 来源
经典题目- 上传者
张云聪
import java.awt.Point;
import java.util.Scanner;
public class InsertedRectengle{
static void main(String[] args) {
InsertedRectengle insertedRectengle = new
InsertedRectengle();
insertedRectengle.solution();
solution() {
new Scanner(System.in);
in.nextInt();
0; i < groups; i++) {
in.nextInt();
= new Point[size];
0; j < size; j++) {
in.nextInt();
in.nextInt();
y) {
y;
y;
x;
new Point(x, y);
sort(list);
= new int[size];
1;
;
1 ; k < size ; k++){