-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTableDecorations.cpp
More file actions
39 lines (30 loc) · 882 Bytes
/
TableDecorations.cpp
File metadata and controls
39 lines (30 loc) · 882 Bytes
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
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
long long rgb[3];
cin >> rgb[0] >> rgb[1] >> rgb[2];
sort(rgb, rgb + 3);
long long result = rgb[0];
rgb[1] -= result;
rgb[2] -= result;
int temp = rgb[1] / 3;
result += temp * 2;
rgb[1] = rgb[1] % 3;
rgb[2] = rgb[2] % 3;
if(rgb[1] > 0 && rgb[2] > 0) {
if(rgb[1] * 2 <= rgb[2]) { // rgb[1]이 0이되므로 더이상 연산 불가
result += rgb[1];
} else {
int pairNum = rgb[2] / 2;
// 만약 rgb[2] % 2 == 1이라면 g가 2 이상이면 또 페이를 만들 수 있으므로 ++ 해 준다.
if(rgb[2] % 2 == 1 && rgb[1] - pairNum >= 2) {
pairNum++;
}
result += pairNum;
}
}
cout << result <<'\n';
return 0;
}