-
Notifications
You must be signed in to change notification settings - Fork 1
/
PermutingTwoArrays.cpp
executable file
·51 lines (41 loc) · 1.01 KB
/
PermutingTwoArrays.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int t;
int n;
int k;
bool result;
auto cmp = [](int a, int b ){
return a > b ;
};
vector< int > a;
vector< int > b;
cin >> t;
while( t-- ){
cin >> n >> k;
a.clear();
b.clear();
result = true;
a = vector< int >( n );
b = vector< int >( n );
for( int i = 0 ; i < n ; ++i ){
cin >> a[ i ];
}
for( int i = 0 ; i < n ; ++i ){
cin >> b[ i ];
}
sort( a.begin(), a.end() );
sort( b.begin(), b.end(), cmp );
for( int i = 0 ; i < n ; ++i ){
if( a[ i ] + b[ i ] < k ) result = false;
}
if( result ) cout << "YES\n";
else cout << "NO\n";
}
return 0;
}