首页 > 其他 > 详细

P1003 铺地毯

时间:2019-03-25 18:32:06      阅读:134      评论:0      收藏:0      [点我收藏+]

直接从后面向前面找就可以了。

#include<iostream>
using namespace std;
const int maxn = 1e4 + 10;
struct node{
    int x1, y1, x2, y2;
}num[maxn];

int n, x, y, a, b, ans=-1;

int main(){
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> x >> y>>a>>b;
        num[i].x1 = x; num[i].y1 = y;
        num[i].x2 = x + a; num[i].y2 = y + b;
    }
    cin >> x >> y;
    for (int i = n; i >= 1; --i)
    if (num[i].x1 <= x&&num[i].y1 <= y&&num[i].x2 >= x&&num[i].y2 >= y){ ans = i; break; }

    cout << ans << endl;
}

 

P1003 铺地毯

原文:https://www.cnblogs.com/ALINGMAOMAO/p/10595407.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!