URAL1991 The battle near the swamp 2017-04-12 18:07 92人阅读 评论(0) 收藏
The battle near the swamp
Jar Jar: What? Mesa no have a booma!
Gungan: Here. Taken dis one.
order to get the droids of the Federation out from the capital. The gungan ruler Boss Nass was so grateful for uniting the nations that he appointed Jar Jar a general.
have a foolproof weapon against droids, which is small energy balls called boom booms. One such ball can disable exactly one droid.
of boom booms that will be left unused and the number of droids that will survive the attack. You can assume that when a boom boom is fired at a droid by a gungan, it always hits the target.
the number of boom-booms in the i-th truck.
input | output |
---|---|
4 5 |
2 8 |
—————————————————————————————————————
题目的意思是给出n个地区,每个地区有ai个机器人,每个地区投放k歌炸弹,每个炸弹可以炸死1个机器人,问最后幸存的机器人数量和剩下的炸弹的数量
#include <iostream>
#include <cstdio>
using namespace std; int main()
{
int x,y,a;
while(~scanf("%d%d",&x,&y))
{
int ans1=0,ans2=0;
for(int i=0;i<x;i++)
{
scanf("%d",&a);
if(y>a) ans1+=y-a;
else ans2+=a-y;
}
printf("%d %d\n",ans2,ans1);
}
return 0;
}
URAL1991 The battle near the swamp 2017-04-12 18:07 92人阅读 评论(0) 收藏的更多相关文章
- cubieboard变身AP 分类: ubuntu cubieboard 2014-11-25 14:04 277人阅读 评论(0) 收藏
加载bcmdhd模块:# modprobe bcmdhd 如果你希望开启 AP 模式,那么:# modprobe bcmdhd op_mode=2 在/etc/modules文件内添加bcmdhd o ...
- HDU6029 Graph Theory 2017-05-07 19:04 40人阅读 评论(0) 收藏
Graph Theory Time Limit: 2000/1000 M ...
- hdu 1159, LCS, dynamic programming, recursive backtrack vs iterative backtrack vs incremental, C++ 分类: hdoj 2015-07-10 04:14 112人阅读 评论(0) 收藏
thanks prof. Abhiram Ranade for his vedio on Longest Common Subsequence 's back track search view in ...
- 哈希-Gold Balanced Lineup 分类: POJ 哈希 2015-08-07 09:04 2人阅读 评论(0) 收藏
Gold Balanced Lineup Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13215 Accepted: 3873 ...
- Gold Coins 分类: POJ 2015-06-10 15:04 16人阅读 评论(0) 收藏
Gold Coins Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21767 Accepted: 13641 Desc ...
- Segment Tree 分类: ACM TYPE 2014-08-29 13:04 97人阅读 评论(0) 收藏
#include<iostream> #include<cstdio> using namespace std; struct node { int l, r, m; int ...
- ubuntu14.04使用root用户登录桌面 分类: 学习笔记 linux ubuntu 2015-07-05 10:30 199人阅读 评论(0) 收藏
ubuntu安装好之后,默认是不能用root用户登录桌面的,只能使用普通用户或者访客登录.怎样开启root用户登录桌面呢? 先用普通用户登录,然后切换到root用户,然后执行如下命令: vi /usr ...
- Windows Media Player axWindowsMediaPlayer1 分类: C# 2014-07-28 12:04 195人阅读 评论(0) 收藏
属性/方法名: 说明: [基本属性] URL:String; 指定媒体位置,本机或网络地址 uiMode:String; 播放器界面模式,可为Full, Mini, None, Invisible p ...
- iOS开发之监听键盘高度的变化 分类: ios技术 2015-04-21 12:04 233人阅读 评论(0) 收藏
最近做的项目中,有一个类似微博中的评论转发功能,屏幕底端有一个输入框用textView来做,当textView成为第一响应者的时候它的Y值随着键盘高度的改变而改变,保证textView紧贴着键盘,但又 ...
随机推荐
- 【白银组】codevs_1011 数的计算
简单而言,就是递归的运用,注意使用全局变量统计cnt,并且注意递归的结束,中间生成的值无需进行输出. http://codevs.cn/problem/1011/ #include<iostre ...
- java微信 客服接口-发消息 中文乱码
/** * 向指定 URL 发送POST方法的请求 * * @param url * 发送请求的 URL * @param param * 请求参数,请求参 ...
- MOCTF - WriteUp
最新更新已转移至个人博客http://rasang.site 1.一道水题 题如其名,查看源代码就可以看到flag 2.还是水题 尝试输入,发现输入失败,于是F12直接修改数据 直接删除disable ...
- map、reduce处理数据结构及常见案例
随着三大前端框架和小程序的流行,MVVM大行其道,而其中的核心是 ViewModel 层,它就像是一个中转站(value converter),负责转换 Model 中的数据对象来让数据变得更容易管理 ...
- HDU King (非连通图的差分约束,经典好题)
King Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- 关系型数据库与Key-value型数据库Mongodb模式设计对比
MongoDb 相比于传统的 SQL 关系型数据库,最大的不同在于它们的模式设计( Schema Design )上的差别,正是由于这一层次的差别衍生出其它各方面的不同. 我们可以简单的认为关系型数据 ...
- 细说Cookie(转)
原文地址:http://www.cnblogs.com/fish-li/archive/2011/07/03/2096903.html#undefined Cookie虽然是个很简单的东西,但它又是W ...
- mysql-5.6.20主从同步错误之Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND
mysql-5.6.20主从同步错误之Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND 方法一: 1.Error_code: 1032; ha ...
- Selenium Webdriver——Xpath轴定位(preceding)
1.preceding-sibling 选取当前节点之前的所有同级节点 text=出发之前的同级节点: 2.preceding 选取当前节点开始标签之前的所有节点 text=出发节点标签之前的所有i ...
- leetcode38
public class Solution { public string CountAndSay(int n) { //1 //11 //21 //1211 //111221 //312211 // ...