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. OpenSSL生成root CA及签发证书

    一.openssl 简介 openssl 是目前最流行的 SSL 密码库工具,其提供了一个通用.健壮.功能完备的工具套件,用以支持SSL/TLS 协议的实现.官网:https://www.openss ...

  2. VC6 快捷键

    F1: 帮助 Alt+F8   : 自动缩进Ctrl+O   :OpenCtrl+P   :PrintCtrl+N   :NewCtrl+Shift+F2 :清除所有书签F2    :上一个书签Shi ...

  3. 介绍一个开源的 C++ 开发框架 openFrameworks 。

    作为一个图形图像方向的研究生,我经常都在和 OpenGL .OpenCV 等多种 C++ 库打交道.这些库遵循着不同的规则和用法:另外,为了让自己的程序具有更多的交互能力,编写界面也是一个家常便饭的工 ...

  4. MAMP pro mac 本地集成环境 php sal apache等集成软件

    http://www.sdifen.com/mamppro411.html 已存在我的百度云盘 安装后,打开  MAMP 第一步:配置启动和停止选项 默认启动项.默认停止项,只需要勾选: 1.Star ...

  5. Java利用ScriptEngineManager对计算公式的支持

    1.ScriptEngineManager是JDK6提出的相关方法,这方式的主要目的就是用来对脚本语言的处理.这里只是简单介绍一下对我们常用的数学公式的应用. 2.ScriptEngineManage ...

  6. PHP session 跨子域问题总结 ini_set('session.cookie_domain', ".domain.com")

    Session主要分两部分: 一个是Session数据,该数据默认情况下是存放在服务器的tmp文件下的,是以文件形式存在 另一个是标志着Session数据的Session Id,Session ID, ...

  7. OpenCL Hello World

    ▶ OpenCL 的环境配置与第一个程序 ● CUDA 中自带 OpenCL 需要的头文件和库,直接拉近项目里边去就行:AMD 需要下载 AMD APP SDK(https://community.a ...

  8. 阻止后续事件的发生 onclick 双return 事件绑定(..$).click一个return

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. 使用 phpStorm 开发

    苦恼蛋疼的曾哥工作室,让人痛不欲生,缓慢的同步速度,另人恼火的插件配置,让人疯狂的卡.简直是让人用了几天之后就不行了. 废话不多说,一款很好的php IDE. 1. phpStorm 下载 here ...

  10. bootargs中ip段各项解释

    目标板:合众达的SEED-DVS6467开发板 内核版本:2.6.10 最近同事测试板卡nfs挂载PC的文件系统时出现点问题,PC上ifconfig中显示以太网为eth3,然而板卡启动参数列表相关信息 ...