85, 求助
查看原帖
85, 求助
162196
伟大的王夫子楼主2020/8/15 15:15
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55];
	int __f, qr, _eof;
#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout), oS = obuf;
	}
	inline void gc (char &x) {
		x = Gc();
	}
	inline void pc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	inline void pstr (const char *s) {
		int __len = strlen(s);
		for (__f = 0; __f < __len; ++__f) pc (s[__f]);
	}
	inline void gstr (char *s) {
		for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' ' && __c != '\n' && __c != '\r'; ++s, __c = Gc()) *s = __c;
		*s = 0;
	}
	template <class I> inline bool gi (I &x) {
		_eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) {
			if (__c == '-') __f = -1;
			_eof |= __c == EOF;
		}
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF;
		x *= __f;
		return !_eof;
	}
	template <class I> inline void print (I x) {
		if (!x) pc ('0');
		if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) pc (qu[qr --]);
	}
	struct Flusher_ {
		~Flusher_() {
			flush();
		}
	} io_flusher_;
} using io::pc;
using io::gc;
using io::pstr;
using io::gstr;
using io::gi;
using io::print;
#define For(i, a, b) for (register int i = a; i <= b; ++i)
__int128 S, L, n;
__int128 h[200010], a[200010];
bool valid(__int128 x) {
	__int128 sum = 0;
	For (i, 1, n) if (x * a[i] + h[i] >= L) sum += x * a[i] + h[i];
	return sum >= S;
}
int main() {
	gi(n), gi(S), gi(L);
	For (i, 1, n) gi(h[i]);
	For (i, 1, n) gi(a[i]);
	__int128 l = 0, r = 1e9;
	while (l < r) {
		int mid = (l + r) >> 1;
		if (valid(mid)) r = mid;
		else l = mid + 1;
	}
	print(l);
}
2020/8/15 15:15
加载中...