Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- DirectX11
- 오블완
- RVO
- GeeksForGeeks
- Frustum
- baekjoon
- 팰린드롬 만들기
- NRVO
- RootMotion
- 언리얼엔진5
- winapi
- 백준
- 티스토리챌린지
- softeer
- 프로그래머스
- 1563
- IFileDialog
- C
- UnrealEngine5
- Unreal Engine5
- 2294
- Programmers
- UE5
- TObjectPtr
- const
- algorithm
- C++
- directx
- 줄 세우기
- UnrealEngine4
Archives
- Today
- Total
Game Develop
[Algorithm] Baekjoon 16987번 : 계란으로 계란치기 본문
https://www.acmicpc.net/problem/16987
16987번: 계란으로 계란치기
원래 프로그래머의 기본 소양은 팔굽혀펴기를 단 한 개도 할 수 없는 것이라고 하지만 인범이는 3대 500을 넘기는 몇 안되는 프로그래머 중 한 명이다. 인범이는 BOJ에서 틀린 제출을 할 때마다 턱
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
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
67
68
69
|
struct Node
{
int s;
int w;
};
int n, a, b;
vector<Node> eggs;
int answer = 0;
void DFS(int index)
{
if (index >= n)
{
int count = 0;
for (int i = 0; i < n; ++i)
{
if (eggs[i].s <= 0) ++count;
}
answer = max(answer, count);
return;
}
bool check = false;
if (eggs[index].s <= 0) DFS(index + 1);
else
{
for (int i = 0; i < n; ++i)
{
if (i == index) continue; // 자기 자신이면 넘어가기.
if (eggs[i].s <= 0) continue; // 깨져있으면 넘어가기.
check = true;
eggs[index].s -= eggs[i].w; // 서로 딜교
eggs[i].s -= eggs[index].w; //
DFS(index + 1);
eggs[index].s += eggs[i].w;
eggs[i].s += eggs[index].w;
}
if (!check) DFS(n);
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
for (int i = 0; i < n; ++i)
{
cin >> a >> b;
eggs.push_back({ a,b });
}
DFS(0); //
cout << answer;
}
|
cs |
문제를 풀이하는게 제일 어려웠던 것 같다. 그냥 이해를 잘 못한걸수도 있긴한데, 좀더 명확하게 수행해야할 동작에 대해서 설명하면 좋지 않았을까..한다.
'Algorithm > Baekjoon' 카테고리의 다른 글
[Algorithm] Baekjoon 2805번 : 나무 자르기 (0) | 2023.04.19 |
---|---|
[Algorithm] Baekjoon 11967번 : 불켜기 (0) | 2023.03.27 |
[Algorithm] Baekjoon 1941번 : 소문난 칠공주 (0) | 2023.03.25 |
[Algorithm] Baekjoon 15649번 : N과 M(1) (0) | 2023.03.25 |
[Algorithm] Baekjoon 17780번 : 새로운 게임 (0) | 2023.03.17 |