QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#543642#1864. Might and MagicPhantomThreshold#WA 2ms3700kbC++201.2kb2024-09-01 17:44:052024-09-01 17:44:06

Judging History

你现在查看的是最新测评结果

  • [2024-09-01 17:44:06]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3700kb
  • [2024-09-01 17:44:05]
  • 提交

answer

#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#define ll long long
#define int long long
using namespace std;

const int maxn = 310000;

int calc(int Cp,int Cm,int D1,int N,int T)
{
	if(N<0) return 0;
	
	int ret=0;
	
	ret=max(ret, Cp*max(1ll, N-D1)*T );
	int tk= (Cm*N-Cp)/(2*Cm);
	if(tk<0) tk=0;
	if(tk>T) tk=T;
	for(int k=tk-2;k<=tk+2;k++)
	{
		if(k>=0 && k<=T)
			ret=max(ret, Cp*(T-k)+Cm*(N-k)*k);
	}
	return ret;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int Tcase; cin>>Tcase;
	while(Tcase--)
	{
		int Cp,Cm,H0,A1,D1,N;
		cin>>Cp>>Cm>>H0>>A1>>D1>>N;
		
		int ans=0;
		if(A1>=H0)
		{
			ans= max( Cp*max(1ll,N-D1),Cm*(N-1) );
			
			N-=A1-H0;
			A1=H0;
		}
		for(int l=1;l<=H0;l++)
		{
			int r= H0/(H0/l);
			
			int D0= A1-min(A1,r);
			if(H0%r==0)
			{
				ans=max(ans, calc( Cp,Cm,D1,N-D0,H0/r ) );
				
				if(l!=r)
				{
					D0= A1-min(A1,r-1);
					ans=max(ans, calc( Cp,Cm,D1,N-D0,H0/r+1 ) );
				}
			}
			else
			{
				ans=max(ans, calc( Cp,Cm,D1,N-D0,H0/r+1 ) );
			}
			l=r;
		}
		cout<<ans<<'\n';
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3700kb

input:

2
1 1 4 5 1 4
2 5 1 9 9 6

output:

4
25

result:

ok 2 number(s): "4 25"

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3596kb

input:

100
1 1000000 1000000 1 1 1000000
1 1 63 17 3 16
5 3 73 3 10 16
5 2 23 20 5 19
5 4 30 16 5 16
1 1 76 14 1 13
374334 265401 231663 11 3 4
204467 215696 313373 10 1 10
457955 456092 253432 17 5 9
643 474603 40411 20 4 7
35009 444310 461190 5 4 11
1 1 142615 53408 206285 486539
1 1 64714 344368 141319 ...

output:

250000000000500000
63
1460
140
150
76
12388583730
64074437191
27308772560
6992810
48437402130
41432081955
144412
295493195
23791
218732
36719904038
102709259153
24982059009
122260194720
318231902520
290946873
222255159
17907356
24315820
372763998
2956984784
6362246448
32442826597326
9141609509
56259...

result:

wrong answer 3rd numbers differ - expected: '300', found: '1460'