Codeforces round #180 (297b)-fish weight

Source: Internet
Author: User

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 ;}

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.