-
[15810] 풍선 공장BOJ 2022. 3. 4. 00:56
https://www.acmicpc.net/problem/15810
15810번: 풍선 공장
1, 2, 3번 스태프가 각각 5분, 7분, 3분씩 걸린다면 3분이 지났을 때 3번 스태프가 1개, 5분에 1번 스태프가 1개, 6분에 3번 스태프가 1개를, 7분에 2번 스태프가 1개를, 9분에 3번 스태프가 1개를, 10분에
www.acmicpc.net
우선순위큐로도 풀릴것만 같은 문제다.
#include <bits/stdc++.h>using namespace std;#ifdef ONLINE_JUDGEconstexpr bool local = false;#elseconstexpr bool local = true;#endifusing ll = long long;using pi = pair<ll, ll>;ll n, m, ans;vector<ll> v;bool f(ll mid) {ll i, cur = 0;for (i = 0; i < n; i++) cur += (mid / v[i]);return cur >= m;}int main(void) {if (!local) ios_base::sync_with_stdio(0), cin.tie(0);cin >> n >> m;v.resize(n);ll i;for (i = 0; i < n; i++) cin >> v[i];ll s = 1, e = 1'000'000'000'000;ans = e;while (s <= e) {ll mid = s + e >> 1;bool ret = f(mid);if (ret == true) {ans = min(mid, ans);e = mid - 1;} elses = mid + 1;}cout << ans;return 0;}
'BOJ' 카테고리의 다른 글
[1256] 사전 (0) 2022.03.06 [15684] 사다리 조작 (0) 2022.03.06 [6236] 용돈 관리 (0) 2022.03.02 [2512] 예산 (0) 2022.03.02 [4195] 친구 네트워크 (0) 2022.03.02