QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#884226#10011. LotteryQingyuTL 0ms0kbC++261.2kb2025-02-05 22:22:292025-02-05 22:22:34

Judging History

This is the latest submission verdict.

  • [2025-02-06 03:29:21]
  • hack成功,自动添加数据
  • (/hack/1522)
  • [2025-02-06 03:22:12]
  • hack成功,自动添加数据
  • (/hack/1521)
  • [2025-02-06 03:14:39]
  • hack成功,自动添加数据
  • (/hack/1520)
  • [2025-02-06 03:05:58]
  • hack成功,自动添加数据
  • (/hack/1519)
  • [2025-02-06 03:02:43]
  • hack成功,自动添加数据
  • (/hack/1518)
  • [2025-02-05 22:22:34]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 0kb
  • [2025-02-05 22:22:29]
  • Submitted

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
int n;
ll s,r;
ll val[303];
ll dp[40004000];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	double st=clock();
	cin>>n>>s>>r;
	int bound=inf;
	for(int i=1;i<=n;i++)
	{
		int a;
		ll b;
		cin>>a>>b;
		val[a]=max(val[a],b);
	}
	ll A=inf,B=1;
	for(int i=1;i<=40000000;i++)
	{
		for(int j=1;j<=i&&j<=300;j++)
			dp[i]=max(dp[i],dp[i-j]+val[j]);
		if(dp[i])
		{
			ll A2=dp[i]*i+r*s;
			ll B2=dp[i];
			if((longer)(B2)*A>(longer)(B)*A2)
			{
				A=A2;
				B=B2;
			}
		}
	}
	ll g=__gcd(A,B);
	cout<<A/g<<" "<<B/g<<'\n';
	return 0;
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

3 11 3
1 3
2 7
5 13

output:


result: