CSU 2256 模拟

http://acm.csu.edu.cn:20080/csuoj/problemset/problem?pid=2256

Description

You have just bought a new house, and it has a huge, beautiful lawn. A lawn that needs cutting. Several times. Every week. The whole summer.

After pushing the lawnmower around the lawn during the hottest Saturday afternoon in history, you decided that there must be a better way. And then you saw the ads for the new robotic lawnmovers. But which one should you buy? They all have different cutting speeds, cutting times and recharge times, not to mention different prices!

According to the advertisement, a robotic lawnmover will spend all its time either cutting the lawn or recharging its battery. Starting from a full battery, it will cut the lawn at a given rate of c square meters per minute for a cutting time of t minutes, after which it has run out of battery. Once out of battery, it will immediately start recharging. After recharging for r minutes the battery is full again and it immediately starts cutting.

You decide that in order for your lawn to look sufficiently prim and proper, the lawnmower that you buy must be powerful enough to cut your whole lawn at least once a week on average. Formally, if we start the mower fully charged at the beginning of the week and run it for exactly T weeks, it needs to cut the whole lawn at least T times, for all positive integers T. But apart from this, you have no specific requirements, so among the ones that satisfy this requirement, you will simply go for the cheapest option. For the purposes of cutting your lawn, you may make the simplifying assumption that a week is always exactly 10 080 minutes long.

Input

The first line of input contains two integers ℓ and m (1 ≤ ℓ ≤ 106, 1 ≤ m ≤ 100), the size of your lawn in square meters, and the number of lawnmowers to consider, respectively.

Then follow m lines, each containing a string n and 4 integers p, c, t, and r, separated by commas, describing a lawnmower as follows:

  • n is the name of the lawnmower, a string of at most 60 printable characters (ASCII 32 to 126) excluding ',', neither starting nor ending with a space,

  • 1 ≤ p ≤ 100 000 is the price of the lawnmover,

  • 1 ≤ c ≤ 100 is the cutting rate in square meters per minute,

  • 1 ≤ t ≤ 10 080 is the cutting time in minutes, and

  • 1 ≤ r ≤ 10 080​ is the recharge time in minutes.

Output

Output the name of the cheapest lawnmower capable of cutting your whole yard at least once a week on average. If several lawnmovers share the same lowest price, output all of their names, in the same order they were given in the input. If there is no such mower, output "no such mower".

Sample Input

7000 4
Grass Slayer 2000,9999,10,120,120
Slow-Mowe,999,1,120,240
Eco-cut X2,5499,2,25,35
Mowepower,5499,3,25,35
------------------------------------------
100000 4
Grass Slayer 2000,9999,10,120,120
Slow-Mowe,999,1,120,240
Eco-cut X2,5499,2,25,35
Mowepower,5499,3,25,35

Sample Output

Eco-cut X2
Mowepower
-----------------------------------
no such mower

Hint

Source

ncpc2018

题目大意:给出草坪的总面积sum以及n种切割机的名称name、价格p、切割速率c(平方米/分钟)、可工作时间t、充电时间r,要求一周内要把草坪修剪完毕,求满足题意的最便宜的切割机的名称,如果有多种选择则全部输出。

思路:模拟题,没什么好说的。熟悉一一下sscanf的用法。

#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;

vector<int> vec[105];
char s[105][1005];
int sum,n,p,c,t,r;
int MIN=INF;
int id=0;

int main()
{
	scanf("%d %d",&sum,&n);
	getchar();
	for(int i=0;i<n;i++)
	{
		gets(s[i]);
		int len=strlen(s[i]);
		int j=0;
		while(s[i][j]!=',')
			++j;
		sscanf(s[i]+j+1,"%d,%d,%d,%d",&p,&c,&t,&r);
		if(sum*1.0/(c*t)*(t+r)>(double)10080)
			continue;
		if(p<MIN)
		{
			MIN=p;
			id=i;
			vec[id].push_back(i);
		}
		else if(p==MIN)
			vec[id].push_back(i);
	}
	if(MIN==INF)
		printf("no such mower\n");
	else
	{
		for(int i=0;i<vec[id].size();i++)
		{
			int to=vec[id][i];
			for(int j=0;s[to][j]!=',';j++)
				putchar(s[to][j]);
			putchar('\n');
		}
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/xiji333/article/details/89737845
今日推荐