Problem

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 10080 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≤100000 is the price of the lawnmover,

1≤c≤100 is the cutting rate in square meters per minute,1≤t≤10080 is the cutting time in minutes, and 1≤r≤10080 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 1 Sample Output 1
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
Eco-cut X2
Mowepower
Sample Input 2 Sample Output 2
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
no such mower

题意:在符合条件T的情况下,选取最小价格,按输入顺序输出。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
char ss[10005];
struct node
{
char name[105];
ll m;
ll p, c, t, g;
double need;
}a[100005];
ll are, n;
bool cmp(struct node a, struct node b)
{
return a.p < b.p;
}
ll ojbk(ll x)
{
ll we = a[x].c * a[x].t;
double ti = are / we * a[x].g + are / we * a[x].t + ((are % we) * 1.0)/ a[x].c;
if(are % we != 0)
{
ti += (are % we) * 1.0 / we * a[x].g;
}
a[x].need = ti;
if(ti <= 10080)return 1;
else return 0;
}
int main()
{ scanf("%lld %lld", &are, &n);
getchar();
ll i, j, k;
ll minn = 0x3f3f3f3f;
for(i = 0; i < n; i++)
{
ll len = 0;
for(len = 0; (ss[len] = getchar()) != '\n'; len++);
a[i].m = 0;
a[i].p = a[i].t = a[i].c = a[i].g = 0;
for(j = 0; j< len; j++)
{
if(ss[j] == ',')
{
a[i].name[a[i].m] = '\0';
break;
}
else
{
a[i].name[a[i].m++] = ss[j];
}
}
for(j++; j < len; j++)
{
if(ss[j] == ',')break;
else
{
a[i].p *= 10;
a[i].p += ss[j] - '0';
}
}
for(j++; j < len; j++)
{
if(ss[j] == ',')break;
else
{
a[i].c *= 10;
a[i].c += ss[j] - '0';
}
}
for(j++; j < len; j++)
{
if(ss[j] == ',')break;
else
{
a[i].t *= 10;
a[i].t += ss[j] - '0';
}
}
for(j++; j < len; j++)
{
if(ss[j] == ',')break;
else
{
a[i].g *= 10;
a[i].g += ss[j] - '0';
}
}
if(ojbk(i) == 1)
{
minn = min(minn,a[i].p);
}
}
if(minn == 0x3f3f3f3f)
{
printf("no such mower\n");
}
else
{
for(i = 0; i < n; i++)
{
if(a[i].p == minn)
{
if(a[i].need <= 10080)
{
printf("%s\n", a[i].name);
}
}
}
}
return 0;
}

House Lawn Kattis - houselawn的更多相关文章

  1. It's a Mod, Mod, Mod, Mod World Kattis - itsamodmodmodmodworld (等差数列求和取模)

    题目链接: D - It's a Mod, Mod, Mod, Mod World Kattis - itsamodmodmodmodworld 具体的每个参数的代表什么直接看题面就好了. AC代码: ...

  2. A - Piece of Cake Kattis - pieceofcake (数学)

    题目链接: A - Piece of Cake Kattis - pieceofcake 题目大意:给你一个多边形,然后给你这个多边形的每个点的坐标,让你从这个n个点中选出k个点,问这个k个点形成的面 ...

  3. Subsequences in Substrings Kattis - subsequencesinsubstrings (暴力)

    题目链接: Subsequences in Substrings Kattis - subsequencesinsubstrings 题目大意:给你字符串s和t.然后让你在s的所有连续子串中,找出这些 ...

  4. G - Intersecting Rectangles Kattis - intersectingrectangles (扫描线)(判断多个矩形相交)

    题目链接: G - Intersecting Rectangles Kattis - intersectingrectangles 题目大意:给你n个矩形,每一个矩形给你这个矩形的左下角的坐标和右上角 ...

  5. E - Emptying the Baltic Kattis - emptyingbaltic (dijkstra堆优化)

    题目链接: E - Emptying the Baltic Kattis - emptyingbaltic 题目大意:n*m的地图, 每个格子有一个海拔高度, 当海拔<0的时候有水. 现在在(x ...

  6. G - Galactic Collegiate Programming Contest Kattis - gcpc (set使用)

    题目链接: G - Galactic Collegiate Programming Contest Kattis - gcpc 题目大意:当前有n个人,一共有m次提交记录,每一次的提交包括两个数,st ...

  7. Kattis - virus【字符串】

    Kattis - virus[字符串] 题意 有一个正常的DNA序列,然后被病毒破坏.病毒可以植入一段DNA序列,这段插入DNA序列是可以删除正常DNA序列中的一个连续片段的. 简单来说就是,给你一段 ...

  8. Kattis - bank 【简单DP】

    Kattis - bank [简单DP] Description Oliver is a manager of a bank near KTH and wants to close soon. The ...

  9. City Destruction Kattis - city dp

    /** 题目:City Destruction Kattis - city 链接:https://vjudge.net/problem/Kattis-city 题意:有n个怪兽,排成一行.每个怪兽有一 ...

随机推荐

  1. ant build打包

    使用ant build进行增量打包 <?xml version="1.0" encoding="gb2312"?> <project name ...

  2. CCF 201709-1 打酱油

    CCF 2017-09-1 打酱油 题目 问题描述 小明带着N元钱去买酱油.酱油10块钱一瓶,商家进行促销,每买3瓶送1瓶,或者每买5瓶送2瓶.请问小明最多可以得到多少瓶酱油. 输入格式 输入的第一行 ...

  3. 在论坛中出现的比较难的sql问题:8(递归问题 树形结构分组)

    原文:在论坛中出现的比较难的sql问题:8(递归问题 树形结构分组) 最近,在论坛中,遇到了不少比较难的sql问题,虽然自己都能解决,但发现过几天后,就记不起来了,也忘记解决的方法了. 所以,觉得有必 ...

  4. sql 视图的用法

    在一个项目的实际开发过程中牵涉到复杂业务的时候,我们不可避免的需要使用中间表来进行数据连接,有的同学就说了,我可以采用Hibernate进行主外键进行关联啊?多对多,多对一,一对一,等,采用主外键关联 ...

  5. 谷歌浏览器调试手机app内置网页

    当自己的H5项目内置于手机app内时,遇到了样式问题或者想查看H5页面代码.数据交互以及缓存等情况来检查数据,此时可以使用谷歌浏览器的控制台远程调试手机,步骤如下: 一.手机开启允许usb调试 二.手 ...

  6. selenium网页截图和截图定位(无界面)phantomjs

    phantomjs是一款软件,需要重新安装. 参考: https://blog.csdn.net/liyahui_3163/article/details/79064108 案例代码: from se ...

  7. 使用SQLAlchemy,以及问题处理

    https://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/0014021031294178 ...

  8. IMSI-catcher:可发现附近手机敏感信息的工具

      严正声明:该工具主要是为了让大家更好的了解GSM网络的工作原理而设计开发的,请不要用于恶意目的! 前言 IMSI-catcher是一个可以帮助你发现附近手机的IMSI号码,国家,品牌和运营商等信息 ...

  9. Introduction of Machine Learning

    李宏毅主页 台湾大学语音处理实验室 人工智慧.机器学习与深度学习间有什么区别? 人工智能——目标 机器学习——手段 深度学习——机器学习的一种方法 人类设定好的天生本能 Machine Learnin ...

  10. C 全局变量 本地变量