CodeForces Round #180 (297B) - Fish Weight
来源:互联网 发布:网络装修公司 编辑:程序博客网 时间:2024/06/05 16:46
由于是 0 < w1 ≤ w2 ≤ ... ≤ wk....当B中排序最后的鱼序号有大于A排序最后的鱼...那么将B的这鱼重量和A当前最大的鱼定为相等..则这两条鱼的重量相抵消 .所以如果这么做..只要A还有鱼..就能保证每次B所有的总重量都不会大于A的总重量...这么抵消下去..一旦A有条鱼的序号大于B所剩的所有鱼..那么A就可以胜利了..因为可以令小于A这条鱼的所有鱼重量无穷小...
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 long #define oo 1000000001#define MAXN 400005using 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%d%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;}
- CodeForces Round #180 (297B) - Fish Weight
- 298D Fish Weight
- Codeforces Beta Round #16 (Div. 2 Only) E. Fish
- Codeforces Round#297 B. Pasha and String
- Codeforces Round #297 (Div. 2) B
- Codeforces Round #180 (Div. 2)-B. Sail
- Codeforces Round #180 (Div. 1) B
- Codeforces Round #136 B
- Codeforces Round #239 --B
- Codeforces Round #300 B
- codeforces round # 412B
- Codeforces Round #425 B
- Codeforces Round #438 B
- Codeforces Round #439 B
- Codeforces Round #439 B
- Codeforces Round #397 B
- Codeforces Round #326 (Div. 1)A. Duff and Weight Lifting
- Codeforces Round #326 (Div. 1)-A. Duff and Weight Lifting
- iOS 中的关于json解析的四种方法
- 矩阵相乘入门,两个矩阵相乘
- ffmpeg 新老接口问题及对照集锦
- 2012年世界500强排行榜(企业名单)
- 打印出菱形
- CodeForces Round #180 (297B) - Fish Weight
- 【C语言】正则表达式学习笔记
- 安装最新版本的CMake
- 黑马韩前成Linux从入门到精通のLinux基本网络配置の原理篇
- Point-Counterpoint:SDN跟数据中心网络架构都将双双失败?
- [学习笔记5]SSL、CMD命令、PDB、000后缀文件
- 面试100题系列之12判断序列是不是查找二叉树的后序编列
- PDF网页显示: object标签使用pdf插件打开中文文件的问题 (WEB开发)
- Handler的介绍