Coconut is Captain Gangplank's favourite fruit. That is why he needs to drink coconut juice from bbb coconuts each day.
On his next trip, he would pass through NNN citis.
His trip would begin in the 111-st city and end in the NNN-th city.
The journey from the iii-th city to the (i+1)(i+1)(i+1)-th city costs DiD_iDi days.
Initially, there is no coconut on his ship. Fortunately, he could get supply of CiC_iCi coconuts from the iii-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 TTT, indicating that there are TTT test cases.
For each test case the first line contains two integers NNN and bbb as described above.
The second line contains NNN integers C1,C2,⋯,CNC_1, C_2, \cdots, C_NC1,C2,⋯,CN.
The third line contains N−1N-1N−1 integers D1,D2,⋯,DN−1D_1, D_2, \cdots, D_{N-1}D1,D2,⋯,DN−1.
All integers in the input are less than 100010001000.
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
题目来源
2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛
题意:》》》》
思路:写了好久了,,,表示思路忘了,,,,
下面附上代码:
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
int a[1100],b[1100];
int main()
{
int T,N,B;
cin>>T;
while(T--)
{
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
cin>>N>>B;
for(int i=0;i<N;i++)
cin>>a[i];
for(int i=0;i<N-1;i++)
cin>>b[i];
int num=0,flag=0;
for(int i=0;i<N-1;i++)
{
if((a[i]+num)<b[i]*B)
{
flag=1;
break;
}
num=(a[i]+num)-b[i]*B;
}
if(flag)
puts("No");
else
puts("Yes");
}
return 0;
}