2020牛客多校第八场 K Kabaleo Lite

题目链接

Tired of boring WFH (work from home), Apollo decided to open a fast
food restaurant, called Kabaleo Lite. The restaurant serves n kinds of
food, numbered from 1 to n. The profit for the i-th kind of food is
ai . Profit may be negative because it uses expensive ingredients. On
the first day, Apollo prepared bi dishes of the i-th kind of food.
The peculiarity of Apollo’s restaurant is the procedure of ordering
food. For each visitor Apollo himself chooses a set of dishes that
this visitor will receive. When doing so, Apollo is guided by the
following rules: every visitor should receive at least one dish. each
visitor should receive continuous kinds of food started from the first
food. And the visitor will receive exactly 1 dish for each kind of
food. For example, a visitor may receive 1 dish of the 1st kind of
food, 1 dish of the 2nd kind of food, 1 dish of the 3rd kind of food.
What’s the maximum number of visitors Apollo can feed? And he wants to
know the maximum possible profits he can earn to have the maximum of
visitors.

The first line of the input gives the number of test case,T
(101≤T≤10). test cases follow.Each test case begins with a line
containing one integers n ( 10^51≤n≤10 5 ), representing the number of
different kinds of food. The second line contains n space-separated
numbers ai(10≤ai≤10 9 ), where ai denotes the profit of one dish of
the i-th kind. The third line contains n space-separated numbers bi
where bi denotes the number of the i-th kind of dishes.

ac代码如下:

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)	
#define T int t ;cin >> t;while(t--)
using namespace std ;
typedef long long ll;
typedef unsigned long long ull;
inline ll gcd(ll a,ll b){
   return b == 0? a:gcd(b, a % b);}
ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值