Because yes 0 < W 1 ≤ W 2 ≤... ≤ W K .... when the final fish number in B is greater than the final fish number in a sorting... so the weight of the fish of B is equal to that of the largest fish of .. the weight of the catfish is offset. so if you do this .. as long as a has fish .. we can ensure that the total weight of B is not greater than the total weight of a every time... so offset .. once a has a fish with a serial number greater than all the fish left by B .. then a can win .. because it can make all the fish less than a have an infinitely small weight...
Program:
// Http://codeforces.com/contest/297/problem/ B #include <iostream> # include <stdio. h> # include <string. h> # include <cmath> # include <algorithm> # include <map> # include <set> # include <queue> # define ll long # define oo 1000000001 # define maxn 400005 using namespace STD; int n, m, K, a [100005], B [100005]; bool judge () {While (M & N & B [m]> = A [n]) m --, n --; If (N &&(! M | A [n]> B [m]) return true; return false;} int main () {int I, j; while (~ Scanf ("% d", & N, & M, & K) {for (I = 1; I <= N; I ++) scanf ("% d", & A [I]); sort (a + 1, A + 1 + n); for (I = 1; I <= m; I ++) scanf ("% d", & B [I]); sort (B + 1, B + 1 + M); If (Judge ()) printf ("Yes \ n"); else printf ("NO \ n");} return 0 ;}