Codeforces Round #311 (Div. 2) A. Ilya and Diplomas

简介:

题目链接:http://codeforces.com/contest/557/problem/A

#include <iostream>

using namespace std;
int minn[3];
int maxx[3];
int main()
{
    int m;
    while(cin>>m)
    {
        int ans[3]={0};
        for(int i=0; i<3; i++)
            cin>>minn[i]>>maxx[i];
        for(int i=0; i<3; i++)
            ans[i]=minn[i];
        m-=(minn[0]+minn[1]+minn[2]);
        for(int i=0; i<3; i++)
        if(m)
        {
            if(ans[i]+m<=maxx[i])
            {
                ans[i]+=m;
                m=0;
            }
            else
            {
                ans[i]=maxx[i];
                m-=(maxx[i]-minn[i]);
            }
        }
        for(int i=0; i<2; i++)
            cout<<ans[i]<<" ";
        cout<<ans[2]<<endl;
    }
    return 0;
}
目录
相关文章
|
7月前
|
人工智能 算法 BI
Codeforces Round #179 (Div. 2)A、B、C、D
我们每次加进来的点相当于k,首先需要进行一个双重循环找到k点和所有点之间的最短路径;然后就以k点位判断节点更新之前的k-1个点,时间复杂度降到O(n^3),而暴力解法每次都要进行floyd,时间复杂度为O(n^4);相比之下前述解法考虑到了floyd算法的性质,更好了运用了算法的内质。
33 0
|
7月前
Codeforces Round #178 (Div. 2)
在n条电线上有不同数量的鸟, Shaass开了m枪,每一枪打的是第xi条电线上的第yi只鸟,然后被打中的这只鸟左边的飞到第i-1条电线上,右边的飞到i+1条电线上,没有落脚点的鸟会飞走。
27 0
|
7月前
Codeforces Round #192 (Div. 2) (330A) A. Cakeminator
如果某一行没有草莓,就可以吃掉这一行,某一列没有也可以吃点这一列,求最多会被吃掉多少块蛋糕。
25 0
|
8月前
Codeforces Round #742 (Div. 2)
Codeforces Round #742 (Div. 2)
27 0
|
人工智能 索引
Codeforces Round 806 (Div. 4)
Codeforces Round 806 (Div. 4)A~G
93 0
Codeforces Round 835 (Div. 4)
Codeforces Round 835 (Div. 4) A~F题解
88 0
Codeforces Round #675 (Div. 2) A~D
Codeforces Round #675 (Div. 2) A~D
100 0