You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
666 B
C++

#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
long long a[N], b[N];
int main()
{
int T, n;
scanf("%d", &T);
while (T--)
{
scanf("%d", &n);
for (int i = n - 1; i >= 0; i--) scanf("%lld", a + i);
for (int i = n - 1; i >= 0; i--) scanf("%lld", b + i);
for (int i = 1; i < n; i++) a[i] += a[i - 1], b[i] += b[i - 1];
bool flag = true;
for (int i = 0; i < n; i++)
if (a[i] > b[i])
flag = false;
puts(flag ? "Yes" : "No");
}
return 0;
}