QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#62360#1864. Might and MagiclmeowdnWA 6ms3652kbC++171.1kb2022-11-18 14:23:372022-11-18 14:23:39

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:23:39]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:3652kb
  • [2022-11-18 14:23:37]
  • 提交

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);
			//magic
			int t=m/2, k=m-t;
			ans=max(ans,cm*k*t+m-k);
			if(k>0) t++, k--;
			ans=max(ans,cm*k*t+m-k);
		}
		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: 3612kb

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: 6ms
memory: 3652kb

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
72
1095
95
150
76
1497336
64074437191
4121595
5695240
32291601420
59180292900
144413
12844935560
23792
747694336
36719904038
102709259153
24982059009
122260194720
318231902520
290947644
222255768
8953991
24315942
372764916
2750950050
6334488510
32442715074308
8405314080
5625926661...

result:

wrong answer 2nd numbers differ - expected: '63', found: '72'