跳到正文

个人记录

1

ZouXihao约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年3月10日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
unsigned long long n,m,k;
struct node{
	unsigned long long s,b;
}a[N];
unsigned long long f(unsigned long long x){
	unsigned long long sum=0;
	for(int i=1;i<=n;i++){
		unsigned long long ans=0;
		ans+=a[i].s+a[i].b*x;
		if(ans>=k) sum+=ans;
	}
	return sum>=m;
}
bool cmp(node x,node y){
	return x.s<y.s;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	unsigned long long l=-1,r=1e16+1;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i].s;
	}
	for(int i=1;i<=n;i++){
		cin>>a[i].b;
	}
	sort(a+1,a+1+n,cmp);
	while(l+1<r){
		int mid=(l+r)/2;
		if(f(mid)){
			r=mid;
		}else{
			l=mid;
		}
	}
	cout<<r;
	return 0;
}
/*unsigned long long*/
原文