3중 for문


<코드>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <queue>
using namespace std;
 
int a[6], b, c;
 
int main() {
    for (int i = 0; i < 6; i++scanf("%d"&a[i]);
    scanf("%d%d"&b, &c);
    for (int i = 0; i < 6; i++for (int j = i + 1; j < 6; j++for (int k = j + 1; k < 6; k++) {
        if (a[i] + a[j] + a[k] == b) {
            priority_queue<int> q;
            q.push(a[i]); q.push(a[j]); q.push(a[k]);
            while (q.size()) printf("%d ", q.top()), q.pop();
            for (int l = 0; l < 6; l++if (l^i && l^j && l^k) q.push(a[l]);
            while (q.size()) printf("%d ", q.top()), q.pop();
            return 0;
        }
    }
    return 0;
}
cs


'BOJ' 카테고리의 다른 글

2917 늑대 사냥꾼  (1) 2017.08.31
3372 보드 점프  (0) 2017.08.31
1884 고속도로  (0) 2017.08.31
10025 게으른 백곰  (0) 2017.08.30
14619 섬 여행  (0) 2017.08.30

+ Recent posts