UVA LA 7146 2014上海亚洲赛(贪心)
/**
UVA LA 7146 2014上海亚洲赛(贪心)
题目大意:给定敌我两方士兵的数量和每一个士兵的攻击力和防守力,假设两个士兵对战。一方的攻击力大于等于还有一方的防守力。那么成功杀死,可能同归于尽
问在我方能够全部杀死地方士兵的情况下,问我方能剩下的士兵最多是多少
解题思路:这题去年在现场没有写出来== 首先要保证的是地方全部人都要被杀死,那么把我方士兵攻击力递减排序。敌方士兵防守力递减排序。枚举敌方的
士兵。将我方全部攻击力大于其防守力的士兵入multiset。然后在当中选择第一个防守力大于当前敌方士兵攻击力的我方士兵,若没有满足的,删除
我方防守力最低的士兵
*/
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
typedef long long LL;
const int maxn=100005;
int m,n;
struct note
{
int x,y;
bool operator < (const note &other)const
{
return x>other.x;
}
}a[maxn],b[maxn]; int main()
{
int T,tt=0;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
{
scanf("%d%d",&a[i].x,&a[i].y);
}
for(int j=0;j<m;j++)
{
scanf("%d%d",&b[j].y,&b[j].x);
}
sort(a,a+n);
sort(b,b+m);
multiset <int> st;
int p=0,ans=n;
for(int i=0;i<m;i++)
{
while(b[i].x<=a[p].x&&p<n)
{
st.insert(a[p++].y);
}
if(st.empty())
{
ans=-1;
break;
}
multiset<int>::iterator it=st.upper_bound(b[i].y);
if(it==st.end())
{
st.erase(st.begin());
ans--;
}
else
st.erase(it);
}
printf("Case #%d: %d\n",++tt,ans);
}
return 0;
}
/**
2
3 2
5 7
7 3
1 2
4 4
2 2
2 1
3 4
1 10
5 6
*/
UVA LA 7146 2014上海亚洲赛(贪心)的更多相关文章
- 2014上海网络赛 HDU 5053 the Sum of Cube
水 #include <stdio.h> #include <stdlib.h> #include<math.h> #include<iostream> ...
- hdu 5053 (2014上海网赛L题 求立方和)
题目大意:给你L到N的范围,要求你求这个范围内的所有整数的立方和. Sample Input2 //T1 32 5 Sample OutputCase #1: 36Case #2: 224 # inc ...
- UVA LIVE 7146 Defeat the Enemy
这个题跟codeforces 556 D Case of Fugitive思路一样 关于codeforces 556 D Case of Fugitive的做法的链接http://blog.csdn. ...
- [蓝桥杯]2014蓝桥省赛B组题目及详解
/*——————————————————————————————————————————————————————————— [结果填空题]T1 题目:啤酒和饮料 啤酒每罐2.3元,饮料每罐1.9元.小 ...
- 2014 ACM广东省赛总结
2014年广东省赛在化工大学城开,5月10日开幕式&热身赛,5月11日正式赛. 热身赛的时候,开幕式说有两小时,于是我们愉快的切题了,像平常组队赛那样很快出了两题,但卡在后面两题切不动了.这时 ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it
链接:https://www.nowcoder.com/acm/contest/163/F 来源:牛客网 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it 时间限制:C ...
- 2018 ACMICPC上海大都会赛重现赛 H - A Simple Problem with Integers (线段树,循环节)
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 H - A Simple Problem with Integers (线段树,循环节) 链接:https://ac.nowcoder.co ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it (扫描线)
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it (扫描线) 链接:https://ac.nowcoder.com/acm/contest/163/F来源:牛客网 时间 ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP)
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP) 链接:https://ac.nowcoder.com/acm/contest/163/ ...
随机推荐
- 《how to design programs》9.3处理任意长度的表
假定一个玩具商店要把货物库存清单存放在计算机之中,这样,店里的员工就可以快速判断商店里是否还有某种玩具存货.简言之,商店需要一个能够检查库存是否含有玩具'doll 的函数contains-doll?, ...
- Educational Codeforces Round 9
Educational Codeforces Round 9 Longest Subsequence 题目描述:给出一个序列,从中抽出若干个数,使它们的公倍数小于等于\(m\),问最多能抽出多少个数, ...
- cf459E Pashmak and Graph
E. Pashmak and Graph time limit per test 1 second memory limit per test 256 megabytes input standard ...
- cf459D Pashmak and Parmida's problem
D. Pashmak and Parmida's problem time limit per test 3 seconds memory limit per test 256 megabytes i ...
- iOS Xcode工程目录的 folder 和 group的区别(蓝色和黄色文件夹的区别)
1. 来自 http://blog.csdn.net/fanjunxi1990/article/details/9352917 XCode工程目录里面,有时你会发现2个不同颜色的文件夹,一种是蓝色的, ...
- get方式中文乱码问题
<a target="_blank" href="ftpFileAction!downloadFile.action?filename=测试.xml"&g ...
- linux中grep使用方法具体解释
查找特定字符串并颜色显示 [root@fwq test]# grep -n 'the' regular_express.txt --color=auto 8:I can't finish the te ...
- Codeforces #245(div2)
A:A. Points and Segments (easy) 题目看了n久,開始认为尼玛这是div2的题目么,题目还标明了easy.. 意思是给你一n个点,m个区间,在n个点上放蓝球或者红球,然后让 ...
- PropertyGrid--基本功能
一.引言 PropertyGrid是Visual Studio中新增的控件,顾名思义,其主要是用来显示和设置某一(或多个)对象的属性值的.其具体的实现主要是基于.Net中强大的反射机制.Propert ...
- asp.net 跨页面传值常用方法
常用方法有以下: 1.queryString 2.form-post控件传递 3.cookie 4.application 5.session querystring: http://website. ...