codeforces 1555A

A. PizzaForces

PizzaForces is Petya’s favorite pizzeria. PizzaForces makes and sells
pizzas of three sizes: small pizzas consist of 6 slices, medium ones
consist of 8 slices, and large pizzas consist of 10 slices each.
Baking them takes 15, 20 and 25 minutes, respectively.

Petya’s birthday is today, and n of his friends will come, so he
decided to make an order from his favorite pizzeria. Petya wants to
order so much pizza that each of his friends gets at least one slice
of pizza. The cooking time of the order is the total baking time of
all the pizzas in the order.

Your task is to determine the minimum number of minutes that is needed
to make pizzas containing at least n slices in total. For example:

if 12 friends come to Petya’s birthday, he has to order pizzas
containing at least 12 slices in total. He can order two small pizzas,
containing exactly 12 slices, and the time to bake them is 30 minutes;
if 15 friends come to Petya’s birthday, he has to order pizzas
containing at least 15 slices in total. He can order a small pizza and
a large pizza, containing 16 slices, and the time to bake them is 40
minutes; if 300 friends come to Petya’s birthday, he has to order
pizzas containing at least 300 slices in total. He can order 15 small
pizzas, 10 medium pizzas and 13 large pizzas, in total they contain
15⋅6+10⋅8+13⋅10=300 slices, and the total time to bake them is
15⋅15+10⋅20+13⋅25=750 minutes; if only one friend comes to Petya’s
birthday, he can order a small pizza, and the time to bake it is 15
minutes. Input The first line contains a single integer t (1≤t≤104) —
the number of testcases.

Each testcase consists of a single line that contains a single integer
n (1≤n≤1016) — the number of Petya’s friends.

Output For each testcase, print one integer — the minimum number of
minutes that is needed to bake pizzas containing at least n slices in
total.

题意: 给你三种烤披萨的方式: 6块–15min,8块–20min,10块–25min,给出一个n代表需求的披萨块数,求最短时间

个人思路:越来越fw了。。。当时想的是贪心,走最大的最大的走完,走中间中间,走完走最小,但是这种局部最优不可能达到全局最优,这道题用dp也不可能,数据大的那么离谱,肯定是也是一步就走的,当时每块的时间算错了就没做了

思路:我们可以仔细观察,就可以发现三种方式得到每一块的时间其实是一样的(1块–2.5min),也就是说选那种其实都可以,那么答案就巨简单了
(我当时为什么会想到dp去呢,,,,)

代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3+10,mod=998244353,INF=0x3f3f3f3f;
int a[N][N];

int main()
{
    int T;cin>>T;
    while(T--)
    {
        ll n;cin>>n;

        cout<<max(6LL,(n+1))/2*5<<endl;
        // /2*5其实就是2.5 +1是因为披萨都是偶数出的 前面的6是用来判断
        // n是特判比6块披萨小的时候
    }
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值