luogu P1003 铺地毯

水题

 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<algorithm>
 4 using namespace std;
 5 template<class T>void read(T &x){
 6     int f=0;x=0;char ch=getchar();
 7     while(ch<'0'||ch>'9')  {f|=(ch=='-');ch=getchar();}
 8     while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
 9     x=f?-x:x;
10 }
11 
12 const int N=10007;
13 int a[N],b[N],g[N],k[N];
14 int n,x,y;
15 
16 int main(){
17     read(n);
18     for(int i=1;i<=n;++i)
19         read(a[i]),read(b[i]),read(g[i]),read(k[i]);
20     read(x),read(y);
21     for(int i=n;i>=1;--i)
22         if(a[i]<=x&&a[i]+g[i]>=x&&b[i]<=y&&b[i]+k[i]>=y){
23             printf("%d
",i);
24             return 0;
25         }
26     printf("-1
");
27     return 0;
28 }
原文地址:https://www.cnblogs.com/Peper/p/9947603.html