金科——铺地毯

import java.util.Scanner;

public class Carpet {
	public static void main(String[] args) {
		Scanner scan  = new Scanner(System.in);
		int n = scan.nextInt();
		int ar[][] = new int[n][4];
		for(int i=0;i<n;i++)
		{
			int a = scan.nextInt();
			int b = scan.nextInt();
			int g = scan.nextInt();
			int k = scan.nextInt();
			
			ar[i][0] =a; 
			ar[i][1] =b;
			ar[i][2]=a+g;
			ar[i][3]=b+k;
		}
		
		int x =scan.nextInt();
		int y =scan.nextInt();
		int  t =0;
		int result=0;
		for(int i =n-1;i>=0&&t==0;i--)
		{ 
			if(x>=ar[i][0]&&x<=ar[i][2]&&y>=ar[i][1]&&y<=ar[i][3])
			{
				t=1;
				result = i+1;
			}
		}
		if(t==0)
			System.out.println(-1);
		else
			System.out.println(result);
		
	}

}

相关文章:

  • 2021-09-09
  • 2021-11-16
猜你喜欢
  • 2022-01-24
  • 2021-10-14
相关资源
相似解决方案