URAL 1991. The battle near the swamp

Source: Internet
Author: User

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 has a booma!
Gungan:here. Taken dis one. In the battle with the trade Federation, Queen Amidala decided-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, grateful for uniting the nations, 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 is well-disciplined soldiers. They stand in neat formation, divided into NBlocks of kDroids each. The Gungans has 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 he army into NParts and give each part a task to destroy the corresponding block of droids. Each of the received a truck with boom booms. Now help General Binks calculate the number of boom booms that'll be is left unused and the number of droids that'll surv Ive the attack. You can assume this when a boom boom was fired at a droid by a Gungan, it always hits the target. Inputthe first line of the input contains numbers Nand k(1≤ N, k≤10 000). The second line contains NNumbers a I(0≤ a I≤100-the number of boom-booms in the I-th truck. Outputprint integers-the number of unused boom booms and the number of survived droids. Sample
input Output
4 52 7) 5 0
2 8




Test instructions: N Army, each army AI soldier, each soldier can destroy an enemy. Every army to go to the place has a k enemy, asked how many soldiers in total useless, how many enemies have not been destroyed.

Analysis: More out of is useless, not enough is to escape the enemy.



AC Code:

#include <cstdio>int main () {    int n, k, ans, Anss, foo;    while (scanf ("%d%d", &n, &k) ==2) {        ans = anss = 0;        while (n--) {            scanf ("%d", &foo);            if (foo > k) ans + = foo-k;            else Anss + = K-foo;        }        printf ("%d%d\n", ans, anss);    }    return 0;}


URAL 1991. The battle near the swamp

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.