QOJ.ac

QOJ

ID提交记录ID题目HackerOwner结果提交时间测评时间
#1519#884387#10011. LotterybulijiojiodibuliduobulijiojiodibuliduoSuccess!2025-02-06 03:05:402025-02-06 03:05:42

詳細信息

Extra Test:

Wrong Answer
time: 1ms
memory: 3840kb

input:

2 1036 1036
299 298
300 299

output:

1880596 897

result:

wrong answer 1st numbers differ - expected: '312366', found: '1880596'

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#884387#10011. LotterybulijiojiodibuliduoWA 9ms3840kbC++171.5kb2025-02-06 02:35:472025-02-06 03:06:33

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int M=300;

int n,b[333];
int f[M+10];
ll s,r;
struct frac {
	ll a,b;
};
bool operator < (frac a, frac b) {
	return (__int128)a.a*b.b<(__int128)b.a*a.b;
}
int main() {
	scanf("%d%lld%lld",&n,&s,&r);
	s*=r;
	rep(i,0,n) {
		int a,c;
		scanf("%d%d",&a,&c);
		b[a]=max(b[a],c);
	}
	int op=-1;
	rep(i,1,301) {
		if (op==-1||b[i]*op>b[op]*i) op=i;
	}
	f[0]=0;
	rep(i,0,M) rep(j,1,301) if (i>=j) {
		f[i]=max(f[i],f[i-j]+b[j]);
	}
	frac ans{1ll<<60,1};
	rep(i,0,M) {
		//(i + a[op] * t) + s / (f[i] + b[op] * t)
		int tt=int(max(sqrt(1.*s/op/b[op]) - 1.*f[i]/b[op],0.0));
		for (ll t=max(tt-10,0);t<=tt+10;t++) if (f[i]+b[op]*t>0) {
			frac p{s,f[i]+b[op]*t};
			p.a=p.a+(i+op*t)*(f[i]+b[op]*t);
			if (p<ans) ans=p;
		}
	}
	ll d=gcd(ans.a,ans.b);
	printf("%lld %lld\n",ans.a/d,ans.b/d);
}