//https://www.acmicpc.net/problem/2309 #include <iostream> |
#include <algorithm> |
using namespace std; |
int h[10]; |
int main() |
{ |
int sum=0; |
bool chk=0; |
for(int i=1; i<=9; i++) { cin >> h[i]; sum+=h[i]; } |
sort(h+1,h+10); |
bool index[10]={0,}; |
for(int i=1; i<=8; i++) |
{ |
for(int j=i+1; j<=9; j++) |
{ |
if(sum-h[i]-h[j]==100) |
{ |
index[i]=1; index[j]=1; |
chk=1; |
break; |
} |
} |
if(chk) break; |
} |
for(int i=1; i<=9; i++) |
if(!index[i]) cout << h[i] << endl; |
} |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
180130_10026_적록색약 (0) | 2018.01.30 |
---|---|
180129_14888_연산자 끼워넣기 (0) | 2018.01.29 |
180126_1065_한수 (0) | 2018.01.26 |
180126_2819_격자판의 숫자 이어 붙이기 (0) | 2018.01.26 |
180126_2616_소형기관차 (0) | 2018.01.26 |
//https://www.acmicpc.net/problem/2309 #include <iostream> |
#include <algorithm> |
using namespace std; |
int h[10]; |
int main() |
{ |
int sum=0; |
bool chk=0; |
for(int i=1; i<=9; i++) { cin >> h[i]; sum+=h[i]; } |
sort(h+1,h+10); |
bool index[10]={0,}; |
for(int i=1; i<=8; i++) |
{ |
for(int j=i+1; j<=9; j++) |
{ |
if(sum-h[i]-h[j]==100) |
{ |
index[i]=1; index[j]=1; |
chk=1; |
break; |
} |
} |
if(chk) break; |
} |
for(int i=1; i<=9; i++) |
if(!index[i]) cout << h[i] << endl; |
} |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
180130_10026_적록색약 (0) | 2018.01.30 |
---|---|
180129_14888_연산자 끼워넣기 (0) | 2018.01.29 |
180126_1065_한수 (0) | 2018.01.26 |
180126_2819_격자판의 숫자 이어 붙이기 (0) | 2018.01.26 |
180126_2616_소형기관차 (0) | 2018.01.26 |