Search

일곱 난쟁이

Created
2021/03/23 01:58
문제 번호
2309
카테고리
브루트포스

Memo

Code

제출 날짜

@8/3/2019

메모리

1984 KB

시간

0 ms
#include <iostream> #include <algorithm> #define LITTLE 9 #define HEIGHT 100 using namespace std; int dwarf[LITTLE]; int getSumOfHeight(int dwarf[]); void getSolution(int sum); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); for(int i = 0; i < LITTLE; i++){ cin >> dwarf[i]; } getSolution(getSumOfHeight(dwarf)); sort(dwarf, dwarf + LITTLE); for(int i = 2; i < LITTLE; i++) { cout << dwarf[i] << "\n"; } return 0; } int getSumOfHeight(int dwarf[]){ int sum = 0; for(int i = 0; i < LITTLE; i++) { sum += dwarf[i]; } return sum; } void getSolution(int sum) { for(int i = 0; i < LITTLE - 1; i++) { for(int j = i + 1; j < LITTLE; j++) { if(sum - dwarf[i] - dwarf[j] == HEIGHT) { dwarf[i] = -1; dwarf[j] = -1; return; } } } }
C++