Ural 1991 The battle near the swamp

在这篇文章中,我们跟随Jar Jar Binks将军和他的Gungan军队,他们在沼泽边与贸易联盟的机器人军队展开战斗。通过合理分配Gungan的炸弹,他们能够有效地摧毁敌方机器人并计算剩余的未使用炸弹数量以及幸存的机器人数量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

点击打开题目链接

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

Sample

input output
4 5
2 7 5 0
2 8
水题

代码:

#include <cstdio>
#include <cstring>
#include<iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n,k;
    int a[10005];
    while(~scanf("%d%d",&n,&k))
    {
        int sum=0,ans=0;
        for(int i=0;i<n;i++)
        {
             scanf("%d",&a[i]);
             if(a[i]<=k)
               sum+=a[i];
             else
             { sum+=k;ans+=a[i]-k;}
        }
      sum=n*k-sum;
     printf("%d %d\n",ans,sum);

    }
    return 0;
}





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值