守恒法的问题,表示,刚刚看了一点点
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
int T, n;
bool flag;
int num[10005];
int ans[10005];
int sux[10005];
int sum[10005];
cin>>T;
while(T--)
{
memset(num, 0, sizeof(num));
memset(sum, 0, sizeof(sum));
memset(ans, 0, sizeof(ans));
memset(sux, 0, sizeof(sux));
flag = true;
cin>>n;
for(int i = 1; i <= n; i++)
{
cin>>num[i];
sum[i] = sum[i-1] + num[i];
}
for(int i = 1; i <= n; i++)
{
cin>>ans[i];
sux[i] = sux[i-1] + ans[i];
}
sort(sum+1, sum+1+n);
sort(sux+1, sux+1+n);
for(int i = 1; i <= n; i++)
if(sum[i]!=sux[i]) flag = false;
if(flag) printf("Yes\n");
else printf("No\n");
}
return 0;
}