QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#591816 | #7079. Array | Afterlife# | WA | 18ms | 32700kb | C++20 | 1.5kb | 2024-09-26 18:03:48 | 2024-09-26 18:03:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=4e18;
const int N=155;
int ha,hb;
ll hc,pa,pb,pc;
ll dp[N][N][N];
#define ckmin(x,y) x=min(x,y);
ll calc(int t,int i,int j){
ll tot=0;
if(i)tot+=pa;
if(j)tot+=pb;
if(hc>1LL*t*(t+1)/2-i-j)tot+=pc;
return tot;
}
ll sum(ll t){
return t*(t+1)/2;
}
ll Get(int t,int i,int j){
if(hc<=sum(t)-i-j)return inf;
ll nt=t;
while(sum(nt)-i-j<hc)++nt;
++nt;
if(i+nt<ha||j+nt<hb)return inf;
ll tot=(nt-t)*pc;
if(i<ha)tot+=(nt-t)*pa+pa;
if(j<hb)tot+=(nt-t)*pb+pb;
if(i<ha&&j<hb)tot+=min(pa,pb);
return tot;
}
void Solve(){
cin>>ha>>hb>>hc>>pa>>pb>>pc;
memset(dp,0x3f,sizeof(dp));
dp[0][0][0]=0;
ll ans=Get(0,0,0);
for(int t=1;t<N;++t){
for(int i=0;i<N;++i){
for(int j=0;j<N;++j){
ll w=dp[t-1][i][j]+calc(t-1,i,j);
if(i+t<N){
ckmin(dp[t][i+t][j],w);
}
if(j+t<N){
ckmin(dp[t][i][j+t],w);
}
ckmin(dp[t][i][j],w);
if(calc(t,i,j)==0){
ans=min(ans,dp[t][i][j]);
}
else{
ans=min(ans,Get(t,i,j)+dp[t][i][j]);
}
}
}
}
cout<<ans<<'\n';
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin>>T;
while(T--)Solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 18ms
memory: 32700kb
input:
1 4 1 2 3 4
output:
0
result:
wrong answer 1st words differ - expected: '22', found: '0'