P1003 铺地毯

水题

#include <bits/stdc++.h>
using namespace std;
const int maxn = 10005;
int n;
int x, y, i;
struct Carp
{
	int a, b, g, k;
} cars[maxn];
bool ok() {
	int left = cars[i].a;
	int right = cars[i].a + cars[i].g;
	int up = cars[i].b + cars[i].k;
	int down = cars[i].b;
	if(left <= x && right >= x && up >= y && down <= y) {
		return true;
	}
	return false;
}
int main(int argc, char const *argv[])
{
	cin >> n;
	for (i = 1; i <= n; ++i)
	{
		cin >> cars[i].a >> cars[i].b >> cars[i].g >> cars[i].k;
	}
	cin >> x >> y;
	for(i = n; i >= 1; i--) {
		if(ok()) break;
	}
	if(i) cout << i;
	else cout << -1;
	return 0;
}

posted on 2016-10-29 15:38  蒟蒻konjac  阅读(132)  评论(0编辑  收藏  举报