문제
https://school.programmers.co.kr/learn/courses/30/lessons/86053
아이디어1
파라매트릭 서치
- 조건을 통해 원하는 값을 찾아감
long long start = 0;
long long end = 2 * 1e9 * 2 * 1e5;
while(start + 1 < end)
{
long long total = 0;
long long gold = 0;
long long silver = 0;
long long mid = (start + end) / (long long)2;
for (int i = 0; i < g.size(); ++i)
{
long long times = mid / t[i];
times = (times >> 1) + (times & 1);
long long weight = times * w[i];
total += min(weight, (long long)g[i] + (long long)s[i]);
gold += min(weight, (long long)g[i]);
silver += min(weight, (long long)s[i]);
}
if ((total >= a + b) && (gold >= a) && (silver >= b))
end = mid;
else
start = mid;
}
return end;