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
- Frustum
- 줄 세우기
- Unreal Engine5
- NRVO
- const
- C
- UE5
- 티스토리챌린지
- baekjoon
- GeeksForGeeks
- DirectX11
- UnrealEngine5
- C++
- 2294
- 언리얼엔진5
- softeer
- 팰린드롬 만들기
- 1563
- 프로그래머스
- 백준
- Programmers
- UnrealEngine4
- DeferredRendering
- RVO
- 오블완
- algorithm
- IFileDialog
- winapi
- RootMotion
- directx
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 16638번 :: 괄호 추가하기 2 (0) | 2025.02.03 |
---|---|
[Algorithm]Baekjoon 1174번 :: 줄어드는 수 (0) | 2025.02.02 |
[Algorithm]Baekjoon 1507번 :: 궁금한 민호 (0) | 2025.01.25 |
[Algorithm]Baekjoon 6236번 :: 용돈 관리 (0) | 2025.01.25 |
[Algorithm]Baekjoon 2352번 :: 반도체 설계 (0) | 2025.01.25 |