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 |
Tags
- C
- 1563
- RootMotion
- 언리얼엔진5
- RVO
- 줄 세우기
- 2294
- UE5
- 티스토리챌린지
- winapi
- 오블완
- Programmers
- softeer
- 백준
- TObjectPtr
- UnrealEngine5
- algorithm
- IFileDialog
- GeeksForGeeks
- UnrealEngine4
- Unreal Engine5
- 팰린드롬 만들기
- DirectX11
- C++
- Frustum
- directx
- const
- baekjoon
- NRVO
- 프로그래머스
Archives
- Today
- Total
Game Develop
[Algorithm]Baekjoon 10819번 :: 차이를 최대로 본문
https://www.acmicpc.net/problem/10819
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
|
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <functional>
#include <sstream>
#include <memory.h>
#include <deque>
#include <set>
#include <unordered_set>
#include <thread>
#include <atomic>
using namespace std;
int n;
int arr[8];
bool visited[8] = { false };
int answer = 0;
void DFS(int index, int sum, int visitedCount)
{
if (visitedCount == n)
{
answer = max(answer, sum);
return;
}
for (int i = 0; i < n; ++i)
{
if (visited[i]) continue;
visited[i] = true;
DFS(i, sum + abs(arr[index] - arr[i]), visitedCount + 1);
visited[i] = false;
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
for (int i = 0; i < n; ++i)
{
cin >> arr[i];
}
for (int i = 0; i < n; ++i)
{
visited[i] = true;
DFS(i, 0, 1);
visited[i] = false;
}
cout << answer;
}
|
cs |
숫자배열을 아무렇게나 해도되지만 계산할때는 순서대로 해야하는 규칙이 있다
=> 순서있는 숫자뽑기를 해주면 된다.
'Algorithm > Baekjoon' 카테고리의 다른 글
[Algorithm]Baekjoon 6236번 :: 용돈 관리 (0) | 2025.03.17 |
---|---|
[Algorithm]Baekjoon 1507번 :: 궁금한 민호 (0) | 2025.03.17 |
[Algorithm]Baekjoon 1174번 :: 줄어드는 수 (0) | 2025.03.17 |
[Algorithm]Baekjoon 1939번 :: 중량제한 (0) | 2025.03.17 |
[Algorithm]Baekjoon 3020번 :: 개똥벌레 (0) | 2025.03.17 |