Defeat the Enemy UVALive - 7146

 

  Long long ago there is a strong tribe living on the earth. They always have wars and eonquer others. One day, there is another tribe become their target. The strong tribe has decide to terminate them!!! There are villages in the other tribe. Each village contains a troop with attack power EAttacki, and defense power EDefensei. Our tribe has troops to attack the enemy. Each troop also has the attack power Attacki, and defense power Defensei. We can use at most one troop to attack one enemy village and a troop can only be used to attack only one enemy village. Even if a troop survives an attack, it can’t be used again in another attack.

  The battle between 2 troops are really simple. The troops use their attack power to attack against the other troop simultaneously. If a troop’s defense power is less than or equal to the other troop’s attack power, it will be destroyed. It’s possible that both troops survive or destroy.

The main target of our tribe is to destroy all the enemy troops. Also, our tribe would like to have most number of troops survive in this war.

Input

  The first line of the input gives the number of test cases, Ttest cases follow. Each test case start with 2 numbers and m, the number of our troops and the number of enemy villages. lines follow, each with Attackand Defensei, the attack power and defense power of our troops. The next lines describe the enemy troops. Each line consist of EAttackand EDefensei, the attack power and defense power of enemy troops

Output

  For each test ease, output one line containing ‘Case #xy’, where is the test case number (starting from 1) and is the max number of survive troops of our tribe. If it‘s impossible to destroy all enemy troops, output ‘-1’ instead.

Limits:

1≤ ≤100,

1≤ n,m ≤105,

1≤ Attacki,Defensei,EAttacki,EDefense≤109,

Sample Input

2

3 2

5 7

7 3

1 2

4 4

2 2

2  1

3  4

1 10

5 6

Sample Output

Case #1: 3

Case #2: -1

 

很久以前,地球上有一个强大的部落生活着。他们总是有战争和其他人。有一天,有另一个部落成为他们的目标。强大的部落决定终止他们!另一个部落有m个村庄。每个村庄都有一支攻击力量EAttacki和防御力量EDefensei的部队。我们的部落有n个部队来攻击敌人。每个部队还拥有攻击力Attacki和防御力Defensei。我们最多可以使用一个部队攻击一个敌方村庄,部队只能用来攻击一个敌方村庄。即使一个部队在袭击中幸存,它也不能在另一次袭击中再次使用。

两支部队之间的战斗非常简单。部队利用其攻击力同时攻击对方。如果一个部队的防御力小于或等于另一部队的攻击力,它将被破坏。两个部队都有可能生存或摧毁。

我们部落的主要目标是摧毁所有的敌军。此外,我们的部落希望在这场战争中有大量的部队生存下来。

 

这题和我的上一篇随笔差不多,一样的原理,stl在ACM里面作用非常大啊

注意multiset的运用

 

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<cmath>
 4 #include<algorithm>
 5 #include<queue>
 6 #include<set>
 7 #include<cctype>
 8 using namespace std;
 9 struct node {
10     int x,y;
11 } a[100010],b[100010];
12 int cmp1(node a,node b) {
13     return a.x>b.x;
14 }
15 int cmp2(node a,node b) {
16     return a.y>b.y;
17 }
18 
19 int main() {
20     int n,t,cas=1,m;
21     scanf("%d",&t);
22     while(t--) {
23         scanf("%d%d",&n,&m);
24         multiset<int>ms;
25         multiset<int>::iterator it;
26         for (int i=0 ; i<n ; i++)
27             scanf("%d%d",&a[i].x,&a[i].y);
28         for (int i=0 ; i<m ; i++)
29             scanf("%d%d",&b[i].x,&b[i].y);
30         sort(a,a+n,cmp1);
31         sort(b,b+m,cmp2);
32         int ans=0,flag=1;
33         for (int i=0 ,j=0; i<m ; i++ ) {
34             while(j<n && a[j].x>=b[i].y ) {
35                 ms.insert(a[j++].y);
36             }
37             if (ms.empty()) {
38                 flag=0;
39                 break;
40             }
41             it=ms.upper_bound(b[i].x);
42             if (it==ms.end()) it=ms.begin();
43             if (*it<=b[i].x)  ans++;
44             ms.erase(it);
45         }
46         printf("Case #%d: %d\n",cas++,flag?(n-ans):-1);
47     }
48     return 0;
49 }

 

转载于:https://www.cnblogs.com/qldabiaoge/p/8530719.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
4S店客户管理小程序-毕业设计,基于微信小程序+SSM+MySql开发,源码+数据库+论文答辩+毕业论文+视频演示 社会的发展和科学技术的进步,互联网技术越来越受欢迎。手机也逐渐受到广大人民群众的喜爱,也逐渐进入了每个用户的使用。手机具有便利性,速度快,效率高,成本低等优点。 因此,构建符合自己要求的操作系统是非常有意义的。 本文从管理员、用户的功能要求出发,4S店客户管理系统中的功能模块主要是实现管理员服务端;首页、个人中心、用户管理、门店管理、车展管理、汽车品牌管理、新闻头条管理、预约试驾管理、我的收藏管理、系统管理,用户客户端:首页、车展、新闻头条、我的。门店客户端:首页、车展、新闻头条、我的经过认真细致的研究,精心准备和规划,最后测试成功,系统可以正常使用。分析功能调整与4S店客户管理系统实现的实际需求相结合,讨论了微信开发者技术与后台结合java语言和MySQL数据库开发4S店客户管理系统的使用。 关键字:4S店客户管理系统小程序 微信开发者 Java技术 MySQL数据库 软件的功能: 1、开发实现4S店客户管理系统的整个系统程序; 2、管理员服务端;首页、个人中心、用户管理、门店管理、车展管理、汽车品牌管理、新闻头条管理、预约试驾管理、我的收藏管理、系统管理等。 3、用户客户端:首页、车展、新闻头条、我的 4、门店客户端:首页、车展、新闻头条、我的等相应操作; 5、基础数据管理:实现系统基本信息的添加、修改及删除等操作,并且根据需求进行交流信息的查看及回复相应操作。
现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本微信小程序医院挂号预约系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此微信小程序医院挂号预约系统利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的MySQL数据库进行程序开发。微信小程序医院挂号预约系统有管理员,用户两个角色。管理员功能有个人中心,用户管理,医生信息管理,医院信息管理,科室信息管理,预约信息管理,预约取消管理,留言板,系统管理。微信小程序用户可以注册登录,查看医院信息,查看医生信息,查看公告资讯,在科室信息里面进行预约,也可以取消预约。微信小程序医院挂号预约系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。
The Mongol Empire was one of the largest empires in history, stretching from Eastern Europe to Asia. It was founded by Genghis Khan in 1206 and lasted until the mid-14th century. The empire was known for its military prowess, innovative tactics, and the use of terror to intimidate its enemies. Genghis Khan was born in 1162 in the region that is now Mongolia. He was born into a family of nomads and grew up herding sheep and hunting. At the age of 16, he was captured by a rival tribe and enslaved. He escaped and later began to unite the various tribes of the region under his leadership. In 1206, he was declared the supreme ruler of the Mongol Empire. Under Genghis Khan's leadership, the Mongol Empire began to expand rapidly. Genghis Khan was a brilliant military strategist and his army was known for its speed and mobility. The Mongols were also skilled horsemen and archers, and they were able to defeat much larger armies using innovative tactics such as feigned retreats and surprise attacks. After Genghis Khan's death in 1227, his empire was divided among his four sons. Over the next few decades, the Mongol Empire continued to expand under the leadership of Genghis Khan's descendants. They conquered China, Central Asia, and parts of Eastern Europe. The Mongols were known for their brutality and the use of terror to intimidate their enemies. They were also tolerant of other religions and cultures, and they allowed conquered peoples to retain their own customs and traditions. One of the most famous Mongol leaders was Kublai Khan, who ruled China from 1279 to 1294. He founded the Yuan Dynasty, which was the first foreign dynasty to rule China. Kublai Khan was a patron of the arts and literature, and he encouraged the development of new technologies such as paper money and gunpowder. He also sent emissaries to Europe, including Marco Polo, who wrote about his travels in China. The Mongol Empire began to decline in the mid-14th century. The empire had become too large to be effectively governed, and there were internal divisions and conflicts among the ruling families. The Black Death, which swept through Europe and Asia in the mid-14th century, also had a devastating impact on the Mongol Empire. By the end of the 14th century, the Mongol Empire had disintegrated into several smaller states. Despite its reputation for brutality, the Mongol Empire had a significant impact on world history. The Mongols were responsible for the spread of ideas, technologies, and cultures across Eurasia. They also played a role in the development of international trade and commerce. The Mongol Empire was a significant force in world history, and its legacy can still be felt today.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值