QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#62362 | #1864. Might and Magic | lmeowdn | WA | 6ms | 3632kb | C++17 | 1.2kb | 2022-11-18 14:32:34 | 2022-11-18 14:32:35 |
Judging History
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 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+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: 3632kb
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: 3584kb
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 95 80 76 1497336 2044670 4121595 5695240 10663448 41432372472 144413 295500408 23792 273415 36719904038 102709259153 24982059009 122260194720 318231902520 290947644 222255768 8953991 24315942 372764916 133553290 2945444070 127756463562 176374998 240454816992 242305688551476...
result:
wrong answer 4th numbers differ - expected: '70', found: '95'