problem Description
The so-called weak country does not have diplomacy, the Acdream kingdom wants to hold this piece of land, naturally cannot leave the kingdom's soldiers, you as the kingdom's King general, naturally has the duty which trains the Kingdom soldier. The kingdom has n soldiers, each soldier has two attributes, attacks and defenses. Then you want to go through a series of adjustments, each soldier can become a qualified soldier, so-called qualified soldiers, refers to his attack and defense of greater than or equal to K. Your adjustment is to swap the same attribute of two soldiers, that is, swapping two soldiers for an attack, or defending the exchange, or exchanging attacks and defenses (though this is meaningless). There is no limit to the number of adjustments you have. Can you make all the soldiers a qualified soldier, please?
Input
Multiple sets of data, each set of data is first two integers n (1<=n<=1000), K (1<=k<=10^9) Next is a line of integers, a total of N, representing the attack value of N soldiers
Next is a line of integers, a total of N, representing the defensive values of N soldiers.
Output
For each set of data, if you can pass the limited exchange, so that all soldiers are qualified soldiers, the output "YES", otherwise output "no" (do not need double quotes, note case)
Code
#include <cstdio>#include <algorithm>using namespace STD;intMain () {intNLong LongK, a[1005], b[1005]; while(scanf("%d%lld", &n, &k)! = EOF) { for(inti =0; I < n; i++)scanf("%lld", &a[i]); for(inti =0; I < n; i++)scanf("%lld", &b[i]); Sort (A, a + N); Sort (b, B + N);BOOLOK =true; for(inti =0; I < n && OK; i++)if(A[i] + b[n-i-1] < K) OK =false;printf("%s\n"Ok?"YES":"NO"); }return 0;}
1715 soldiers of the Acdream kingdom