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 由 温婕莺