P5116 [USACO18DEC] Mixing Milk B

 

 

#include<bits/stdc++.h>
using namespace std;
int c[4],m[4];
int main()
{
    for(int x=1;x<=3;x++)cin>>c[x]>>m[x];
    for(int x=1;x<=100;x++){
        int f=(x-1)%3+1,s;
        if(f==3)s=1;
        else s=f+1;
        int mi=min(c[s]-m[s],m[f]); 
        m[f]-=mi; 
        m[s]+=mi; 
    }
    cout<<m[1]<<endl<<m[2]<<endl<<m[3];
    return 0;
}
View Code

 

 
posted @ 2023-07-28 10:18  JMXZ  阅读(3)  评论(0)    收藏  举报