The battle near the swamp


Gungan: Jar Jar, usen da booma! 

Jar Jar: What? Mesa no have a booma! 

Gungan: Here. Taken dis one.
In the battle with the Trade Federation, Queen Amidala decided to ask gungans for help. Jar Jar Binks escorted the Queen and her people to the holy place where they had an agreement. The gungans agreed to provide their army in
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.
And here they are: two armies lined up along the bank of the swamp. The droids of the Federation are well-disciplined soldiers. They stand in neat formation, divided into n blocks of k droids each. The gungans
have a foolproof weapon against droids, which is small energy balls called boom booms. One such ball can disable exactly one droid.
Jar Jar Binks also decided to split his army into n parts and give each part a task to destroy the corresponding block of droids. Each part received a truck with boom booms. Now help general Binks calculate the number
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.
Input
The first line of the input contains numbers n and k (1 ≤ nk ≤ 10 000). The second line contains n numbers a i (0 ≤  a i ≤ 100 000) —
the number of boom-booms in the i-th truck.
Output
Print two integers — the number of unused boom booms and the number of survived droids.
Example
input output
4 5
2 7 5 0
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) 收藏的更多相关文章

  1. cubieboard变身AP 分类: ubuntu cubieboard 2014-11-25 14:04 277人阅读 评论(0) 收藏

    加载bcmdhd模块:# modprobe bcmdhd 如果你希望开启 AP 模式,那么:# modprobe bcmdhd op_mode=2 在/etc/modules文件内添加bcmdhd o ...

  2. HDU6029 Graph Theory 2017-05-07 19:04 40人阅读 评论(0) 收藏

    Graph Theory                                                                 Time Limit: 2000/1000 M ...

  3. 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 ...

  4. 哈希-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 ...

  5. Gold Coins 分类: POJ 2015-06-10 15:04 16人阅读 评论(0) 收藏

    Gold Coins Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21767   Accepted: 13641 Desc ...

  6. 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 ...

  7. ubuntu14.04使用root用户登录桌面 分类: 学习笔记 linux ubuntu 2015-07-05 10:30 199人阅读 评论(0) 收藏

    ubuntu安装好之后,默认是不能用root用户登录桌面的,只能使用普通用户或者访客登录.怎样开启root用户登录桌面呢? 先用普通用户登录,然后切换到root用户,然后执行如下命令: vi /usr ...

  8. Windows Media Player axWindowsMediaPlayer1 分类: C# 2014-07-28 12:04 195人阅读 评论(0) 收藏

    属性/方法名: 说明: [基本属性] URL:String; 指定媒体位置,本机或网络地址 uiMode:String; 播放器界面模式,可为Full, Mini, None, Invisible p ...

  9. iOS开发之监听键盘高度的变化 分类: ios技术 2015-04-21 12:04 233人阅读 评论(0) 收藏

    最近做的项目中,有一个类似微博中的评论转发功能,屏幕底端有一个输入框用textView来做,当textView成为第一响应者的时候它的Y值随着键盘高度的改变而改变,保证textView紧贴着键盘,但又 ...

随机推荐

  1. HttpHelp 请求帮助类

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net ...

  2. Oracle使用startup与startup force启动的区别

    1. startup 就是正常启动数据库,没什么好说的. 2. startup force 是shutdown abort + startup的组合,即强制关闭数据库+ 正常启动数据库,想快速重启数据 ...

  3. 马士兵Spring-hibernate整合

    spring整合hibernate: 1.sessionFactory只需要一个就可以了,单例,适合spring管理: 2.HIbernate中的SessionFactory是接口:spring中实现 ...

  4. appium -ios-安卓 获取元素时 配置参数的方法

    iPhone_5S{ "automationName": "XCUITest", "platformName": "iOS&quo ...

  5. MySQL 数据库查询练习

    -- ---------------------------- -- mysql练习sql脚本 -- ---------------------------- create database db10 ...

  6. HDU 4762 Cut the Cake(高精度)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  7. 【ZZ】各类程序开发语言概述 | 菜鸟教程

    http://www.runoob.com/w3cnote/programming-intro.html 各类程序开发语言概述, 点击查看大图:

  8. [转][ASP.NET]ASP.NET 预编译网站

    [转自]https://msdn.microsoft.com/zh-cn/library/ms227430(v=vs.80).aspx C:\Windows\Microsoft.NET\Framewo ...

  9. jquery内容补充

    jquery除了咱们上面讲解的常用知识点之外,还有jquery 插件.jqueryUI知识点 jqueryUI 官网: https://jqueryui.com/ jqueryUI 中文网: http ...

  10. 适应移动端 iPhone & Android 微信页面的一些css属性

    1.-webkit-tap-highlight-color -webkit-tap-highlight-color:rgba(0,0,0,0);//透明度设置为0,去掉点击链接和文本框对象时默认的灰色 ...