본문 바로가기

USACO/Bronze

백준 16769 Mixing Milk (USACO December 2018 Bronze 1번)

문제 링크: https://www.acmicpc.net/problem/16769

 

16769번: Mixing Milk

The first line of the input file contains two space-separated integers: the capacity $c_1$ of the first bucket, and the amount of milk $m_1$ in the first bucket. Both $c_1$ and $m_1$ are positive and at most 1 billion, with $c_1 \geq m_1$. The second and t

www.acmicpc.net

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <bits/stdc++.h>
using namespace std;
 
int c[3], m[3];
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    for(int i = 0; i < 3; i++cin >> c[i] >> m[i];
 
    for(int i = 0; i < 100; i++) {
        int cur = i % 3, nxt = (i + 1) % 3;
        int tmp = m[cur];
        m[cur] = max(0, m[cur] - (c[nxt] - m[nxt]));
        m[nxt] = min(c[nxt], tmp + m[nxt]);
    }
 
    for(int i = 0; i < 3; i++)
        cout << m[i] << '\n';
    return 0;
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter