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月前
Codeforces Round #186 (Div. 2)A、B、C、D、E
Ilya得到了一个礼物,可以在删掉银行账户最后和倒数第二位的数字(账户有可能是负的),也可以不做任何处理。
23 0
|
7月前
Codeforces Round #192 (Div. 2) (330A) A. Cakeminator
如果某一行没有草莓,就可以吃掉这一行,某一列没有也可以吃点这一列,求最多会被吃掉多少块蛋糕。
26 0
|
7月前
Codeforces Round #192 (Div. 2) (329A)C.Purification
Codeforces Round #192 (Div. 2) (329A)C.Purification
22 0
|
人工智能 索引
Codeforces Round 806 (Div. 4)
Codeforces Round 806 (Div. 4)A~G
95 0
Codeforces Round 849 (Div. 4)
Codeforces Round 849 (Div. 4)A~G2题解
90 0
Codeforces Round #640 (Div. 4)
Codeforces Round #640 (Div. 4)
68 0
Codeforces Round #644 (Div. 3)(A~G)
Codeforces Round #644 (Div. 3)(A~G)
98 0
|
机器学习/深度学习
Codeforces Round #723 (Div. 2)B. I Hate 1111
Description You are given an integer x. Can you make x by summing up some number of 11,111,1111,11111,…? (You can use any number among them any number of times). For instance, 33=11+11+11 144=111+11+11+11
143 0
Codeforces Round #723 (Div. 2)B. I Hate 1111

热门文章

最新文章