-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path16237.cpp
66 lines (59 loc) · 904 Bytes
/
16237.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// 16237. 이삿짐센터
// 2021.09.26
// 수학
#include<iostream>
using namespace std;
int main()
{
int a, b, c, d, e;
cin >> a >> b >> c >> d >> e;
int ans = 0;
ans += e;
while (d > 0)
{
d--;
if (a > 0)
{
a--;
}
ans++;
}
while (c > 0)
{
c--;
// 3KG 1개 2KG 1개
if (b > 0)
{
b--;
}
// 3KG 1개 1KG 2개
else if (a > 0)
{
a -= 2;
}
ans++;
}
while (b > 0)
{
b--;
// 2KG 2개 1KG 1개
if (b >= 1)
{
b--;
a--;
}
// 2KG 1개 1KG 3개
else if (a > 0)
{
a -= 3;
}
ans++;
}
while (a > 0)
{
a -= 5;
ans++;
}
cout << ans << endl;
return 0;
}