QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#62380 | #1864. Might and Magic | lmeowdn | WA | 2ms | 3728kb | C++17 | 1.4kb | 2022-11-18 17:20:51 | 2022-11-18 17:20:54 |
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;
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==37818840) {
printf("%lld %lld %lld %lld %lld %lld\n",cp,cm,h0+1,a1,d1,n);
}
}
for(auto x:pans) {
printf("%lld\n",ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3728kb
input:
2 1 1 4 5 1 4 2 5 1 9 9 6
output:
25 25
result:
wrong answer 1st numbers differ - expected: '4', found: '25'