QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#417812#1864. Might and MagicKevin5307WA 9ms3748kbC++231.4kb2024-05-22 22:32:302024-05-22 22:32:39

Judging History

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

  • [2024-05-22 22:32:39]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:3748kb
  • [2024-05-22 22:32:30]
  • 提交

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 main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--)
	{
		int Cp,Cm,H0,A1,D1,N;
		cin>>Cp>>Cm>>H0>>A1>>D1>>N;
		vector<int> vec;
		for(int i=1;i*i<=H0;i++)
		{
			vec.pb(i);
			vec.pb((H0+i-1)/i);
		}
		srt(vec);
		ll ans=0;
		for(auto x:vec)
		{
			ll lim=(x==1?1ll*inf*inf:(H0-1)/(x-1));
			ll lim2=lim/Cp;
			if(lim2<=0) continue;
			ll limD=max(0ll,A1-lim2);
			if(limD>N) continue;
			ll cur=N-limD;
			ans=max(ans,1ll*Cp*x*max(1ll,cur-D1));
			if(x<=cur)
				ans=max(ans,1ll*Cm*x*(cur-x));
			ll mid=(cur-Cp/Cm)/2;
			for(int a=max(0ll,mid-5);a<=min({cur,(ll)x,mid+5});a++)
				ans=max(ans,1ll*Cm*(cur-a)*a+1ll*Cp*(x-a));
		}
		cout<<ans<<endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3748kb

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: 0
Accepted
time: 4ms
memory: 3480kb

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
300
70
60
76
796203
1941264
3648736
5695879
10663440
41432081955
144412
295493195
23791
218732
36719904038
102709259153
24982059009
122260194720
318231902520
290946873
222255159
8953678
24315820
372763998
133449680
2945306265
127756463562
176192604
240454816992
242305688722841
...

result:

ok 100 numbers

Test #3:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

10
21 212 26101 23 13 1456
131673 859132 20994 30773 24134 2355
84859 973 541 109013 96108 163455
1477 5 9 4407 1 104414
191 5748 1963 66 11232 384
798 114 135 57 52795 180526
444 3550 16574 185 24504 129705
3203 944 4 9318 850981 3286
18039 8 14112 374 679 1
1221 4612 53812 196 1163 1

output:

108997914
2022396728
5714999073
154218001
19474224
101929338
17467256700
3101040
18039
1221

result:

ok 10 numbers

Test #4:

score: 0
Accepted
time: 1ms
memory: 3476kb

input:

100
53841 5266 18313 59235 11 299778
648 22 578 1 118 6504
1 1 55 33493 3 119206
52985 532083 306 26 153921 132
1 60 67 127590 68852 215208
260 116391 5 10555 89309 3
969929 3596 4202 35 60109 10274
364 1 50736 36 17598 8282
644 274 119 2 6 9
2 68957 338 6 4 34
49 211290 2515 3 13 28894
114825 51501...

output:

16139755047
4138128
4714105
69702873
351959040
232782
36941708
1134980
2192
19928597
316867387200
23240566890
3986100
311343
3014331168
1830033584
410982660
998578
8781670012
66
69697216
848848080
473
15308579223
114
1022552170722
113138358
1600665
6776064
29492122
23377152
12140920
2869334559
39285...

result:

ok 100 numbers

Test #5:

score: -100
Wrong Answer
time: 9ms
memory: 3544kb

input:

1000
31740 161 23 253 39391 116
189260 1572 23918 151265 257 2643
1088 164 1844 11 26836 413618
169 1 330 939983 387 171957
1638 27337 2014 739 1717 3027
30 3836 41640 704 4865 341
7 53279 99843 71 182 13
383459 31 714233 34 183 45
132 69 2304 4811 5841 20
9227 17 15672 55 20 978
152503 45 26 999309...

output:

31740
451574360
841615872
28995330
125039438
3763116
2239083
766918
1311
16682416
152503
35144
929832817
96
1375
19645395
611673
291108285
360819450
606075
119369271426840
55464178582
112174980
16848193
712
57610
266737
157014
23936960
130082203
16297
43538900736
10339373331760
23930048
57130875750
...

result:

wrong answer 580th numbers differ - expected: '48456', found: '24276'