璟雯院

珺璟如晔,雯华若锦

用户工具

站点工具


icpc:problems:755_two_arrays
problems
名称Two Arrays
题目编号755C
题目链接codeforces.com/…
来源CodeForces
算法分类排序
难易程度容易

Two Arrays

想法

简单的排序

代码实现

#include<cstdio>
#include<algorithm>
 
int n;
int a[110], b[110];
 
int main()
{
	int T;
	scanf("%d", &T);
	for(int t=1; t<=T; ++t)
	{
		scanf("%d", &n);
		for(int i=1; i<=n; ++i)
			scanf("%d", &a[i]);
		for(int i=1; i<=n; ++i)
			scanf("%d", &b[i]);
		std::sort(a+1, a+1+n);
		std::sort(b+1, b+1+n);
		bool flag = false;
		for(int i=1; i<=n; ++i)
		{
			if(a[i] == b[i] || a[i] + 1 == b[i])
				continue;
			flag = true;
			break;
		}
		if(flag)
			printf("NO\n");
		else
			printf("YES\n");
	}
 
	return 0;
}
/app/www/public/data/pages/icpc/problems/755_two_arrays.txt · 最后更改: 2023/09/30 13:56 由 温婕莺