牛客枚举题---铺地毯

铺地毯

  • 覆盖地面某个点的最上面的那张地毯的编号
  • 从后往前枚举,前提是这个点在地毯上面
#include<bits/stdc++.h>

#define maxn 100005

using namespace std;

struct Node{
    int x,y,up,right;
}a[maxn];
int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i].x>>a[i].y>>a[i].right>>a[i].up;
    int x,y;cin>>x>>y;
    for(int i=n;i>=1;i--){
        if(x<a[i].x||y<a[i].y) continue;
        if(x-a[i].x<=a[i].right&&y-a[i].y<=a[i].up) {
            cout<<i<<"\n";return 0;
        }  
    }
    
}
posted @ 2020-06-22 08:53  chstor  阅读(142)  评论(0编辑  收藏  举报