Coconut

  •  时间:200ms
  •  内存:131072K


Coconut is Captain Gangplank's favourite fruit. That is why he needs to drink coconut juice from bb coconuts each day.

On his next trip, he would pass through NN citis.

His trip would begin in the 11-st city and end in the NN-th city.

The journey from the ii-th city to the (i+1)(i+1)-th city costs D_iDi days.

Initially, there is no coconut on his ship. Fortunately, he could get supply of C_iCi coconuts from the ii-th city.

Could you tell him, whether he could drink coconut juice every day during the trip no not?

Input Format

The first line contains an integer TT, indicating that there are TT test cases.

For each test case the first line contains two integers NN and bb as described above.

The second line contains NN integers C_1, C_2, \cdots, C_NC1,C2,,CN.

The third line contains N-1N1 integers D_1, D_2, \cdots, D_{N-1}D1,D2,,DN1.

All integers in the input are less than 10001000.

Output Format

For each case, output Yes if Captain Gangplank could drink coconut juice every day, and otherwise output No.

样例输入


2
4 1
3 2 1 4
1 2 3
4 2
2 4 6 8
3 2 1
样例输出


Yes
No

题意:
他每天要喝 b 个椰奶,他去旅行的图中会经过 n 个城市,第 i 个城市到第 i+1 个城市需要经过 Di 天,他在第 i 个城市可以得到 Ci 个椰奶,让你判断他是否每天都能喝到 b 个椰奶。



#include <iostream>
#include<stdio.h>
using namespace std;

int main()
{
    int n,b,t,c[1010],d[1010],sum;
    scanf("%d",&t);
    while(t--)
    {
        bool t=false;
        scanf("%d %d",&n,&b);
        for(int i=1;i<=n;i++)
            scanf("%d",&c[i]);
        for(int i=1;i<n;i++)
            scanf("%d",&d[i]);
        sum=0;
        for(int i=1;i<n;i++)
        {
            sum+=c[i];
            sum-=d[i]*b;
            if(sum<0)
            {
                t=true;
                break;
            }
        }
        if(t)
            printf("No\n");
        else
            printf("Yes\n");
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值