문제 링크: 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
|
'USACO > Bronze' 카테고리의 다른 글
백준 17027 Shell Game (USACO January 2019 Bronze 1번) (0) | 2020.03.13 |
---|---|
백준 16770 The Bucket List (USACO December 2018 Bronze 2번) (0) | 2020.03.13 |
백준 15763 Team Tic Tac Toe (USACO US Open 2018 Bronze 1번) (0) | 2020.03.11 |
백준 15751 Teleportation (USACO February 2018 Bronze 1번) (0) | 2020.03.07 |
백준 15594 Out of Place (USACO January 2018 Bronze 3번) (0) | 2020.03.06 |