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;
}
目录
相关文章
|
27天前
|
人工智能 测试技术 芯片
Codeforces Round 963 (Div. 2)
Codeforces Round 963 (Div. 2)
|
27天前
|
机器学习/深度学习 人工智能 测试技术
Codeforces Round 960 (Div. 2)
Codeforces Round 960 (Div. 2)
|
4月前
Codeforces Round #567 (Div. 2)
【7月更文挑战第1天】
45 7
Codeforces Round #192 (Div. 2) (329A)C.Purification
Codeforces Round #192 (Div. 2) (329A)C.Purification
41 0
Codeforces Round 799 (Div. 4)
Codeforces Round 799 (Div. 4)
117 0
|
人工智能 BI
Codeforces Round 827 (Div. 4)
Codeforces Round 827 (Div. 4)A~G题解
97 0
Codeforces Round #675 (Div. 2) A~D
Codeforces Round #675 (Div. 2) A~D
152 0