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_iD
i
days.
Initially, there is no coconut on his ship. Fortunately, he could get supply of C_iC
i
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_NC
1
,C
2
,⋯,C
N
.
The third line contains N-1N−1 integers D_1, D_2, \cdots, D_{N-1}D
1
,D
2
,⋯,D
N−1
.
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
不想写题解了 应该都能读懂什么意思
code :
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N;
scanf("%d", &N);
while(N--)
{
int c[1500], d[1500];
int n, b;
int flag = 1;
scanf("%d%d", &n, &b);
int sum = 0;
for(int i = 1; i <= n; i++)
{
scanf("%d", &c[i]);
}
for(int i = 1; i < n; i++)
{
scanf("%d", &d[i]);
}
for(int i = 1; i < n; ++ i)
{
sum += c[i];
sum -= d[i] * b;
if(sum < 0)
{
flag = 0;
break;
}
}
if(flag)
{
printf("Yes\n");
}
else
{
printf("No\n");
}
}
return 0;
}