QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#543612 | #1864. Might and Magic | PhantomThreshold# | WA | 2ms | 3648kb | C++20 | 984b | 2024-09-01 17:30:03 | 2024-09-01 17:30:04 |
Judging History
answer
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#define ll long long
#define int long long
using namespace std;
const int maxn = 310000;
int calc(int Cp,int Cm,int D1,int N,int T)
{
if(N<0) return 0;
int ret=0;
ret=max(ret, Cp*max(1ll, N-D1)*T );
int tk= (Cm*N-Cp)/(2*Cm);
if(tk<0) tk=0;
if(tk>T) tk=T;
for(int k=tk-2;k<=tk+2;k++)
{
if(k>=0 && k<=T)
ret=max(ret, Cp*(T-k)+Cm*(N-k)*k);
}
return ret;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int Tcase; cin>>Tcase;
while(Tcase--)
{
int Cp,Cm,H0,A1,D1,N;
cin>>Cp>>Cm>>H0>>A1>>D1>>N;
int ans=0;
if(A1>=H0)
{
ans= max( Cp*max(1ll,N-D1),Cm*(N-1) );
N-=A1-H0;
A1=H0;
}
for(int l=1;l<=H0;l++)
{
int r= H0/(H0/l);
int use= A1-min(A1,r);
ans=max(ans, calc( Cp,Cm,D1,N-use,H0/r ) );
l=r;
}
cout<<ans<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
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: -100
Wrong Answer
time: 2ms
memory: 3648kb
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 1460 115 150 76 12388209396 64074437191 27306940740 6992167 48437402130 41432081955 144412 295493195 23791 164052 36719904038 102709259153 24982059009 122260194720 318231902520 290946873 222255159 8953678 24315820 372763998 2956984784 6362246448 32442826597326 9141609509 562594...
result:
wrong answer 3rd numbers differ - expected: '300', found: '1460'