P4058 [Code+#1] 木材 90分
  • 板块灌水区
  • 楼主wyc14
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/10/20 20:53
  • 上次更新2024/10/20 22:29:50
查看原帖
P4058 [Code+#1] 木材 90分
741524
wyc14楼主2024/10/20 20:53

求加团: https://www.luogu.com.cn/team/90259#main

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
unsigned long long ans, s, L, h[MAXN], a[MAXN];
int n;
bool check(unsigned long long x)
{
	unsigned long long sum = 0;
	for(int i = 1; i <= n; i++)
	{
		unsigned long long c = h[i] + a[i] * x;
		if(c >= L) sum += c;
	}
	return sum >= s;
}
int main()
{
	cin >> n >> s >> L;
	for(int i = 1; i <= n; i++) cin >> h[i];
	for(int i = 1; i <= n; i++) cin >> a[i];
	if(s == 0)
	{
		cout << 0;
		return 0;
	}
	unsigned long long l = 0, r = 1e18;
	while(l <= r)
	{
		unsigned long long mid = (l + r) >> 1;
		if(check(mid))
		{
			ans = mid;
			r = mid - 1;
		}
		else l = mid + 1;
	}
	cout << ans;
	return 0;
}
2024/10/20 20:53
加载中...