QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#62361#1864. Might and MagiclmeowdnWA 3ms3436kbC++171.2kb2022-11-18 14:26:052022-11-18 14:26:07

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 14:26:07]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3436kb
  • [2022-11-18 14:26:05]
  • 提交

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;

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),cm*(n-1));
		for(int l=1,r;l<=h0;l=r+1) {
			r=h0/(h0/l);
			int x=h0/l+1, d0=max(0ll,a1-r/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+m-k);
			//cout<<"MG "<<cm*k*t+m-k<<endl;
			if(k>0) t++, k--;
			ans=max(ans,cm*k*t+m-k);
			//cout<<"MG "<<cm*k*t+m-k<<endl;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
1095
95
150
76
1497336
64074437191
4121595
5695240
32291601420
41432372472
144413
295500408
23792
273415
36719904038
102709259153
24982059009
122260194720
318231902520
290947644
222255768
8953991
24315942
372764916
2750897601
6334408921
32442715074308
8405222400
56259266616306
...

result:

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