QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#591850#7084. Fighting Against MonstersAfterlife#WA 726ms32732kbC++201.5kb2024-09-26 18:25:042024-09-26 18:25:05

Judging History

你现在查看的是最新测评结果

  • [2024-09-26 18:25:05]
  • 评测
  • 测评结果:WA
  • 用时:726ms
  • 内存:32732kb
  • [2024-09-26 18:25:04]
  • 提交

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<ha)tot+=pa;
    if(j<hb)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=sqrt(2*(i+j+hc))-1;
    while(sum(nt)-i-j<hc)++nt;
    if(i+nt+1<ha||j+nt+1<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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 30ms
memory: 32668kb

input:

2
1 10 100 3 2 1
3 2 1 1 10 100

output:

28
123

result:

ok 2 tokens

Test #2:

score: -100
Wrong Answer
time: 726ms
memory: 32732kb

input:

20
100 100 4465 1 1 1000000000
100 100 4560 1 1 1000000000
100 100 4656 1 1 1000000000
100 100 4753 1 1 1000000000
100 100 4851 1 1 1000000000
100 100 4950 1 1 1000000000
100 100 5050 1 1 1000000000
100 100 5151 1 1 1000000000
100 100 5253 1 1 1000000000
100 100 4372 1 1 1000000000
100 100 4466 1 1 ...

output:

94000000201
95000000201
96000000201
97000000201
98000000201
99000000201
100000000203
101000000205
102000000207
94000000191
95000000193
96000000195
97000000197
98000000199
99000000201
100000000203
101000000116
102000000117
103000000118
1414213596000000000

result:

wrong answer 1st words differ - expected: '94000000194', found: '94000000201'