QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#62382#1864. Might and MagiclmeowdnWA 3ms3616kbC++171.4kb2022-11-18 17:21:542022-11-18 17:21:56

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-18 17:21:56]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3616kb
  • [2022-11-18 17:21:54]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define eb emplace_back
#define fi first
#define se second
#define pc __builtin_popcount
typedef pair<int,int> pii;
typedef vector<int> vi;

long long read() {
	long long res=0, w=1; char c=getchar();
	while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
	while(isdigit(c)) {res=res*10+c-'0'; c=getchar();}
	return res*w;
}

int cp,cm,h0,a1,d1,n,T,ans;

vi pans;

signed main() {
	T=read();
	while(T--) {
		cp=read(), cm=read(), h0=read()-1, a1=read(), d1=read(), n=read();
		ans=max(cp*max(1ll,(n-d1)),cm*(n-1));
		for(int l=1,r;l<=h0;l=r+1) {
			r=h0/(h0/l);
			int y=max(1ll,r/cp)*cp;
			if(y>r) continue;
			int x=h0/l+1, d0=max(0ll,a1-y/cp), m=n-d0;
			//cout<<x<<" "<<l<<" "<<r<<" "<<d0<<" "<<m<<endl;
			if(m<0) continue;
			//physic
			int att=cp*max(1ll,m-d1);
			ans=max(ans,att*x);
			//cout<<"AT "<<att*x<<endl;
			//magic
			int t=m/2, k=m-t;
			if(k>x) k=x, t=m-k;
			ans=max(ans,cm*k*t+cp*(x-k));
			//cout<<"MG "<<k<<" "<<t<<" "<<cm*k*t+m-k<<endl;
			if(k>0) t++, k--;
			ans=max(ans,cm*k*t+cp*(x-k));
			//cout<<"MG "<<k<<" "<<t<<" "<<cm*k*t+m-k<<endl;
		}
		//printf("%lld\n",ans);
		pans.eb(ans);
		if(ans==37816920) {
			printf("%lld %lld %lld %lld %lld %lld\n",cp,cm,h0+1,a1,d1,n);
		}
	}
	for(auto x:pans) {
		printf("%lld\n",x);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3ms
memory: 3488kb

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: 2ms
memory: 3616kb

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: -100
Wrong Answer
time: 3ms
memory: 3436kb

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:

1014 90 911968 1971 54125 3262
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
233...

result:

wrong answer 1st numbers differ - expected: '16139755047', found: '1014'