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 |
Tags
- 라즈비안
- Module.symvers
- .config
- 라즈베리파이3 라즈비안
- 라즈베리파이3
- putty
- GPIO
- 인접행렬
- tftp
- AWS
- uboot
- 일곱 난쟁이
- dfs recursive
- stack
- 디바이스 드라이버
- 라즈베리파이 uboot
- 디바이스드라이버
- gui
- deque
- 최단경로
- 모듈
- 2309
- 백준
- tftp-hpa
- DFS
- u-boot
- STL deque
- 라즈베리파이3 ftfp
- 한수
- tftp 서버
Archives
- Today
- Total
달공이와 임베디드
[백준][2309] 일곱 난쟁이 본문
https://www.acmicpc.net/problem/2309
브루트포스로 분류된 문제이다.
O(n^2) 문제인데, n의 수가 10으로 정해져 있다.
출력시 정렬을 위해, deque를 사용하였다.
#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;
int height[9];
int ans_height[7];
int main()
{
int height_sum = 0;
for (int i=0; i<9; i++)
{
cin >> height[i];
height_sum += height[i];
}
int target_height = height_sum - 100;
int fraud_man1;
int fraud_man2;
for(int i=0; i<9-1; i++)
{
for(int j=i+1; j<9; j++)
{
if (target_height == (height[i] + height[j]))
{
fraud_man1 = height[i];
fraud_man2 = height[j];
goto out;
}
}
}
out:
deque<int> list;
for (int i=0; i<9; i++)
{
if (height[i] != fraud_man1 && height[i] != fraud_man2)
{
list.push_back(height[i]);
}
}
sort(list.begin(), list.end());
for (auto el : list)
{
cout << el << endl;
}
}
Comments