diff --git a/src/week6/BOJ6236/BOJ6236_V1.cpp b/src/week6/BOJ6236/BOJ6236_V1.cpp new file mode 100644 index 0000000..39d45dd --- /dev/null +++ b/src/week6/BOJ6236/BOJ6236_V1.cpp @@ -0,0 +1,54 @@ +#include +using namespace std; +int N,M; +vector inp; +bool check_available(int money) { + int curr = money; + int cnt = 1; + for (int i=0; i M) return false; + } + return true; +} +int main() { + + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + cout.tie(nullptr); + + cin >> N >> M; + int low=INT_MIN,high,mid; + + int sum = 0; + for (int i=0; i> money; + inp.push_back(money); + low = max(low,money); + sum += money; + } + high = sum; + + int ret = high; + while(low <= high) { + mid = (low + high) / 2; + + if (check_available(mid)) { + high = mid - 1; + ret = mid; + } else { + low = mid + 1; + } + } + + cout << ret << '\n'; + + + return 0; +} \ No newline at end of file