From b077e59626cb34d403bf0d0cd75e31212e329f3b Mon Sep 17 00:00:00 2001 From: sh0723 Date: Mon, 29 Jun 2026 13:36:08 +0900 Subject: [PATCH] =?UTF-8?q?19942=20:=20=EB=8B=A4=EC=9D=B4=EC=96=B4?= =?UTF-8?q?=ED=8A=B8=20solve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week4/BOJ19942/BOJ19942_V1.cpp | 79 ++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/week4/BOJ19942/BOJ19942_V1.cpp diff --git a/src/week4/BOJ19942/BOJ19942_V1.cpp b/src/week4/BOJ19942/BOJ19942_V1.cpp new file mode 100644 index 0000000..d163593 --- /dev/null +++ b/src/week4/BOJ19942/BOJ19942_V1.cpp @@ -0,0 +1,79 @@ +#include +using namespace std; +vector ret(5); +int ret_bit =0; +vector> inp; +int m[4]; +int n; +bool check_valid(vector temp) { + for (int i = 0; i < 4; i++) { + if (temp[i] < m[i]) + return false; + } + + return true; +} +bool bitcmp(int a, int b) { + for (int i=0; i> n; + for (int i=0; i<4; i++) { + cin >> m[i]; + + } + + for (int i=0; i()); + for (int j=0; j<5; j++) { + int tmp; + cin >> tmp; + inp[i].push_back(tmp); + } + } + + for (int i=0; i<(1 << n); i++) { + vector tmp(5,0); + for (int j=0; j tmp[4]) { + ret = tmp; + ret_bit = i; + } else if (ret[4] == tmp[4] && bitcmp(i, ret_bit)) { + ret = tmp; + ret_bit = i; + } + } + + } + + if (ret[4] == INT_MAX) { + cout << -1 << '\n'; + } else { + cout << ret[4] << '\n'; + for (int i=0; i