zoukankan      html  css  js  c++  java
  • URAL 1991 The battle near the swamp 水题

    The battle near the swamp

    题目连接:

    http://acm.timus.ru/problem.aspx?space=1&num=1991

    Description

    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 ≤ n, k ≤ 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 Input

    4 5
    2 7 5 0

    Sample Output

    2 8

    Hint

    题意

    有n块,每块有k个怪物

    然后每一块有ai个武器

    问你最后剩下多少个武器,以及多少个怪物没有消灭

    题解:

    水题……

    代码

    #include<bits/stdc++.h>
    using namespace std;
    
    int main()
    {
        int n;
    	long long k;
    	cin>>n>>k;
    	long long ans1 = 0,ans2 = 0;
    	for(int i=1;i<=n;i++)
    	{
    		long long x;
    		cin>>x;
    		if(x>k)ans1+=x-k;
    		if(k>x)ans2+=k-x;
    	}
    	cout<<ans1<<" "<<ans2<<endl;
    }
  • 相关阅读:
    杭电 1596 find the safest road (最短路)
    回溯法——求解N皇后问题
    iptables apache2
    POJ 2586 Y2K Accounting Bug(枚举大水题)
    JAVA学习第十九课(java程序的异常处理 (二))
    XHTML中button加入超链接以及使插入图片与屏幕一样大
    每天一个JavaScript实例-apply和call的使用方法
    【HDU 5384】Danganronpa(AC自己主动机)
    小心APP应用让你成为“透明人”
    第一讲:使用html5——canvas绘制奥运五环
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5370266.html
Copyright © 2011-2022 走看看