B. Choosing Laptop

time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Vasya is choosing a laptop. The shop has n laptops to all tastes.

Vasya is interested in the following properties: processor speed, ram and hdd. Vasya is a programmer and not a gamer which is why he is not interested in all other properties.

If all three properties of a laptop are strictly less than those properties of some other laptop, then the first laptop is considered outdated by Vasya. Among all laptops Vasya does not consider outdated, he chooses the cheapest one.

There are very many laptops, which is why Vasya decided to write a program that chooses the suitable laptop. However, Vasya doesn't have his own laptop yet and he asks you to help him.

Input

The first line contains number n (1 ≤ n ≤ 100).

Then follow n lines. Each describes a laptop as speed ram hdd cost. Besides,

  • speedramhdd and cost are integers
  • 1000 ≤ speed ≤ 4200 is the processor's speed in megahertz
  • 256 ≤ ram ≤ 4096 the RAM volume in megabytes
  • 1 ≤ hdd ≤ 500 is the HDD in gigabytes
  • 100 ≤ cost ≤ 1000 is price in tugriks

All laptops have different prices.

Output

Print a single number — the number of a laptop Vasya will choose. The laptops are numbered with positive integers from 1 ton in the order in which they are given in the input data.

Sample test(s)
input
5
2100 512 150 200
2000 2048 240 350
2300 1024 200 320
2500 2048 80 300
2000 512 180 150
output
4
Note

In the third sample Vasya considers the first and fifth laptops outdated as all of their properties cannot match those of the third laptop. The fourth one is the cheapest among the laptops that are left. Thus, Vasya chooses the fourth laptop.


解题说明:此题采用暴力做法求解,需要比较任意两个电脑的配置,但是要注意一旦某个电脑三个方面的配置都不如另外一个电脑,这个电脑以后就不用考虑了,为了区别,可以把价格设一个很大的值。当全部比较完成以后,从价格中找出一个最小值,这就是需要选择的电脑。


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include<set>
#include <algorithm>
using namespace std;

int main()
{
	int n,s[101],r[101],h[101],c[101],i,min,k,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)  
	{
		scanf("%d %d %d %d",&s[i],&r[i],&h[i],&c[i]);
	}
	for (i=0;i<n;i++)
	{
		for (j=0;j<n;j++) 
		{	
			if(i!=j)
			{
				if ((s[i]<s[j])&&(r[i]<r[j])&&(h[i]<h[j]))
				{
					c[i]=1002;
				}
			}
		}
	}
	k=-1;
	min=1002;
	for (i=0;i<n;i++)
	{
		if (c[i]<min)
		{
			min=c[i];
			k=i;
		}
	}
	printf("%d\n",k+1);
	return 0;
}
	


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值