(校赛)URAL 1991 The battle near the swamp

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 containsn numbers ai (0 ≤ ai ≤ 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.

Sample

input output
4 5
2 7 5 0
2 8

水题,题意难懂

意思:星球大战,有n个区域,每个区域k个目标。

攻击也分成n个组,每组ai个炸弹。每个炸弹炸一个目标。

问最后剩余的目标数和炸弹数。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<limits.h>
using namespace std;
int n,m;

int main()
{
    while(~scanf("%d%d",&n,&m))
    {
        int s=0,sum=0,x;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&x);
            if(x<m)
                s+=(m-x);//记录目标数
            if(x>m)
                sum+=(x-m);//记录炸弹数
        }
        printf("%d %d\n",sum,s);
    }
    return 0;
}

(校赛)URAL 1991 The battle near the swamp

时间: 2024-11-05 12:35:33

(校赛)URAL 1991 The battle near the swamp的相关文章

URAL 1991. The battle near the swamp

1991. The battle near the swamp Time limit: 1.0 second Memory limit: 64 MB 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

(校赛)URAL 1998 The old Padawan

Luke Skywalker is having exhausting practice at a God-forsaken planet Dagoba. One of his main difficulties is navigating cumbersome objects using the Power. Luke's task is to hold several stones in the air simultaneously. It takes complete concentrat

(校赛) URAL 1993 This cheeseburger you don&#39;t need

Master Yoda is the oldest member of the Jedi Council. He conducts preparatory classes of little Younglings up to the moment they get a mentor. All Younglings adore master Yoda and they hope to grow as strong and wise as he is. Just like all little ch

CSU 1425 NUDT校赛 I题 Prime Summation

这个题本来有希望在比赛里面出了的 当时也想着用递推 因为后面的数明显是由前面的推过来的 但是在计算的时候 因为判重的问题 ...很无语.我打算用一个tot[i]来存i的总种树,tot[i]+=tot[j]//j为可以由j推到i的一系列数,但这样是不对的,会产生大量重复计算... 看了下标程才发现要用二维来计算出种类总数,f[i][j]+=sum(f[i-j][k]) 表示在推i数的时候,第一个素数为j的种类数,注意j一定为素数,而且k不能大于j...标程里面处理的比较简练,就学了下他的写法. 至

校赛总结

写写校赛总结....... 这两次校赛是我们组队以后第一次的比赛...第一场打得很拙,第二场还可以吧,第一场校赛--毕竟是期待了很久的校赛,所以感觉还是很紧张,吃饭的时候打了二两,剩了一大半==, 这次我们队名叫 I_Love_High_Math......没走到现场,就快下雨了,真的有点郁闷==.到了以后下雨了,和一个队友被困雨中,,出来以后衣服湿了,一开始就悲剧了...     然后一开场就感觉不好.比赛开始的时候,我去写头文件,然后W说A是水题,然后叫我写,平时都是我写第一题的这次我不想开

NYOJ-682 小媛在努力 (郑大第六届校赛 模拟)

链接:click here 题意: 描述 在多媒体数据处理中,数据压缩算法尤为重要.小媛上完课后就想自己发明一个数据压缩算法.她想呀想,终于想到一个方法.在多媒体数据中有很多数据都是重复的,所以她想把连续相同的数据用数据出现的次数和数据本身表示.例如:1 1 1 2 3 3 3 3 3  压缩后及为3 1 1 2 5 3(表示3个1,1个2和5个3).有想法后小媛就希望把它用代码实现了.但是大家都知道小媛现在整天都忙着苦B的复习考研,连电脑都摸不到.所以她希望作为ACMer的你帮她写一下. 输入

HDU多校赛第9场 HDU 4965Fast Matrix Calculation【矩阵运算+数学小知识】

难度上,,,确实,,,不算难 问题是有个矩阵运算的优化 题目是说给个N*K的矩阵A给个K*N的矩阵B(1<=N<=1000 && 1=<K<=6),先把他们乘起来乘为C矩阵,然后算C^(N*N) 相当于 ABABABABABABAB...=(AB)^(N*N) 不如 A(BA)^(N*N-1)B 因为BA乘得K*K的矩阵,K是比较小的 #include <cstdio> #include <cstdlib> #include <cstr

ZJU校赛 一道计数题

题意是这样的 给定一个n*m的整数矩阵 n和m均小于1000 对这个矩阵删去任意行和列后剩余一个矩阵为M{x1,x2,,,,xm;y1,y2,,,,,yn}表示删除任意的M行N列 对于这个剩下的矩阵,我们考虑其中是否存在特殊的元素,保证这些元素是所在行最大,所在列最小的元素 且非之一. 求对于所有删法,上述元素个数之和 对10^9+7取余. 显然所有删法 有2^(n+m)种 暴力是搞不定的. 于是反过来看,矩阵的元素最多有10^6个 是不是可以考虑每一个元素对最终答案的贡献? 所谓贡献,就是它在

山科第三届校赛总结

这次山科的校赛算是省赛前的一次正式的检验吧,暴露了我们队伍之前训练很多没发现的问题. 比赛的过程真的算是有惊无险,差点就GG... 我们入场晚了一会,我刚读完C题,就发现已经有人过了F题了,我去看F题,是个统计闰年的水题,很快就敲过了.回去想接着看C,感觉也很水,这时cerberux说这个用个map就A了,我让他来敲,可是他好像用的不是很熟练,这道题敲的很慢,交上去还wa了...我回过头仔细看这题,觉得扫一遍统计一次最多连续出现的次数就可以了,这才把这个水题过了.然后我去敲G,G题我出现了很严重