QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#62365 | #1864. Might and Magic | lmeowdn | WA | 6ms | 3628kb | C++17 | 1.3kb | 2022-11-18 14:37:54 | 2022-11-18 14:37:56 |
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-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);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3628kb
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: 6ms
memory: 3544kb
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: 3436kb
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: 1ms
memory: 3484kb
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:
wrong answer 80th numbers differ - expected: '37818840', found: '37816920'