From 26e03541dd75cd61d4c7ec0a38f659fefce4f3ef Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 14 Nov 2021 15:13:46 +0800 Subject: [PATCH] C - Two Arrays https://codeforces.com/contest/1589/submission/135373583 --- CodeForces/1589/C/C.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 CodeForces/1589/C/C.cpp diff --git a/CodeForces/1589/C/C.cpp b/CodeForces/1589/C/C.cpp new file mode 100644 index 00000000..47f636e3 --- /dev/null +++ b/CodeForces/1589/C/C.cpp @@ -0,0 +1,26 @@ +#include + +using namespace std; + +int t, n, a[105], b[105]; + +int main() { + cin >> t; + while (t--) { + bool flag = true; + cin >> n; + for (int i = 0; i < n; i++) { + cin >> a[i]; + } + for (int i = 0; i < n; i++) { + cin >> b[i]; + } + sort(a, a + n); + sort(b, b + n); + for (int i = 0; i < n; i++) { + if (b[i] - a[i] > 1 || b[i] - a[i] < 0) flag = false; + } + cout << (flag ? "YES" : "NO") << endl; + } + return 0; +}