URAL1991-The battle near the swamp

来源:互联网 发布:python pack_into 编辑:程序博客网 时间:2024/06/14 08:39

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

inputoutput
4 52 7 5 0
2 8
Problem Author: Denis Dublennykh (prepared by Egor Shchelkonogov)


题意:有n个区域,每个区域k个目标。攻击也分成n个组,每组ai个炸弹。每个炸弹炸一个目标。问最后剩余的目标数和炸弹数。


#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cmath>#include <set>#include <map>#include <algorithm>#include <vector>#include <stack>#include <queue>using namespace std;const int INF=0x3f3f3f3f;#define LL long longint main(){    int n,m;    while(~scanf("%d%d",&n,&m))    {        int a=0,b=0;        for(int i=0;i<n;i++)        {            int t;            scanf("%d",&t);            if(t>m) a+=t-m;            else b+=m-t;        }        printf("%d %d\n",a,b);    }    return 0;}

0 0