Codeforces Round #180 (Div. 2) D. Fish Weight

http://www.codeforces.com/contest/298/problem/D

题意:Alice有n条鱼和Bob有m条鱼,鱼有k个品种,重量按标号不下降的递增,问A的总重量能否大于B的总重量。

做法:如果A中的每一条鱼在B中都能找到一条鱼大于等于其重量,则A的总重量不可能大于B。

View Code
 1 /*
 2  *Author:       Zhaofa Fang
 3  *Created time: 2013-04-22-11.50
 4  *Language:     C++
 5  */
 6 #include <cstdio>
 7 #include <cstdlib>
 8 #include <sstream>
 9 #include <iostream>
10 #include <cmath>
11 #include <cstring>
12 #include <algorithm>
13 #include <string>
14 #include <utility>
15 #include <vector>
16 #include <queue>
17 #include <map>
18 #include <set>
19 using namespace std;
20 
21 typedef long long ll;
22 #define DEBUG(x) cout<< #x << ':' << x << endl
23 #define FOR(i,s,t) for(int i = (s);i <= (t);i++)
24 #define FORD(i,s,t) for(int i = (s);i >= (t);i--)
25 #define REP(i,n) for(int i=0;i<n;i++)
26 #define REPD(i,n) for(int i=n-1;i>=0;i--)
27 #define PII pair<int,int>
28 #define PB push_back
29 #define MP make_pair
30 #define ft first
31 #define sd second
32 #define lowbit(x) (x&(-x))
33 #define INF (1<<30)
34 
35 
36 int A[100111],B[100111];
37 int main(){
38     //freopen("in","r",stdin);
39     //freopen("out","w",stdout);
40     int n,m,k;
41     while(cin>>n>>m>>k){
42         REP(i,n)cin>>A[i];
43         REP(i,m)cin>>B[i];
44         sort(A,A+n); sort(B,B+m);
45         int i = 0,j = 0;
46         while(i<n && j<m){
47             if(A[i]<=B[j])i++,j++;
48             else j ++;
49         }
50         if(i>=n)puts("NO");
51         else puts("YES");
52     }
53     return 0;
54 }

 

posted @ 2013-04-22 12:42  發_  阅读(247)  评论(0编辑  收藏  举报