Coconut is Captain Gangplank's favourite fruit. That is why he needs to drink coconut juice from bcoconuts each day.
On his next trip, he would pass through N citis.
His trip would begin in the 1-st city and end in the N-th city.
The journey from the i-th city to the (i+1)-th city costs Di days.
Initially, there is no coconut on his ship. Fortunately, he could get supply of Ci coconuts from the i-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 T, indicating that there are T test cases.
For each test case the first line contains two integers N and b as described above.
The second line contains N integers C1,C2,⋯,CN.
The third line contains N−1 integers D1,D2,⋯,DN−1.
All integers in the input are less than 1000.
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瓶饮料,城市间距离Di天,城市补充Ci瓶。问是否能每天喝?
思路:
签到。
//
// main.cpp
// C
//
// Created by zc on 2017/9/14.
// Copyright © 2017年 zc. All rights reserved.
//
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=1100;
int c[N],d[N];
int main(int argc, const char * argv[]) {
int T,n,b;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&b);
for(int i=0;i<n;i++) scanf("%d",&c[i]);
for(int i=0;i<n-1;i++) scanf("%d",&d[i]);
int sum=0,flag=0;
for(int i=0;i<n-1;i++)
{
sum+=c[i]-d[i]*b;
if(sum<0)
{
flag=1;
break;
}
}
printf(flag?"No\n":"Yes\n");
}
}