QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#417808 | #1864. Might and Magic | Kevin5307 | WA | 4ms | 3748kb | C++23 | 1.3kb | 2024-05-22 22:27:30 | 2024-05-22 22:27:30 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
{
int Cp,Cm,H0,A1,D1,N;
cin>>Cp>>Cm>>H0>>A1>>D1>>N;
vector<int> vec;
for(int i=1;i*i<=H0;i++)
{
vec.pb(i);
vec.pb((H0+i-1)/i);
}
srt(vec);
ll ans=0;
for(auto x:vec)
{
ll lim=(x==1?1ll*inf*inf:(H0-1)/(x-1));
ll lim2=lim/Cp;
if(lim2<=0) continue;
ll limD=max(0ll,A1-lim2);
if(limD>N) continue;
ll cur=N-limD;
ans=max(ans,1ll*Cp*x*max(1ll,cur-D1));
if(cur/2<=x)
ans=max(ans,1ll*Cm*((cur+1)/2)*(cur/2));
else
ans=max(ans,1ll*Cm*x*(cur-x));
}
cout<<ans<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3748kb
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: 4ms
memory: 3508kb
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:
250000000000000000 63 300 70 60 76 796203 1941264 3648736 5695236 10663440 41432081955 144412 295483104 23791 218732 36719904038 102709259153 24982059009 122260194720 318231902520 290946873 222255159 8953678 24315820 372763998 133449680 2945306265 127756463562 176192604 240454816992 242305688355810 ...
result:
wrong answer 1st numbers differ - expected: '250000000000500000', found: '250000000000000000'