QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#728532#5978. Runaway Quailspdarkle23 ✓1019ms5248kbC++141.6kb2024-11-09 15:22:252024-11-09 15:22:26

Judging History

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

  • [2024-11-09 15:22:26]
  • 评测
  • 测评结果:23
  • 用时:1019ms
  • 内存:5248kb
  • [2024-11-09 15:22:25]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define N 505
#define db double
int n,m,C,in[N];
db f[N][N];
struct node{
    int x,v;
    node(){
        x=v=0;
    }
    node(int _x,int _v){
        x=_x,v=_v;
    }
    bool operator<(const node b)const {
        return x<b.x;
    }
}L[N],R[N];
void sol(){
    cin>>C>>n;int nl=0,nr=0;
    for(int i=1,x;i<=n;++i){
        cin>>x;in[i]=x;
        if(x<0)L[++nl].x=-x;
        else R[++nr].x=x;
    }
    for(int i=1,nl=0,nr=0,v;i<=n;++i){
        cin>>v;
        if(in[i]<0)L[++nl].v=v;
        else R[++nr].v=v;
    }
    sort(L+1,L+nl+1);sort(R+1,R+nr+1);
    for(int i=0;i<=nl;++i)for(int j=0;j<=nr;++j)f[i][j]=1e18;
    f[0][0]=0;db ans=1e18;
    for(int i=0;i<=nl;++i)for(int j=0;j<=nr;++j)if(f[i][j]<1e18){
        db w=0;
        for(int k=i+1;k<=nl;++k){
            w=max(w,1.0*(L[k].x+L[k].v*f[i][j])/(C-L[k].v));
            f[k][j]=min(f[k][j],f[i][j]+w+w);
            // cout<<i<<" "<<j<<' '<<k<<" "<<w<<" L\n";
            if(k==nl&&j==nr)ans=min(ans,f[i][j]+w);
        }
        w=0;
        for(int k=j+1;k<=nr;++k){
            w=max(w,1.0*(R[k].x+R[k].v*f[i][j])/(C-R[k].v));
            f[i][k]=min(f[i][k],f[i][j]+w+w);
            // cout<<i<<" "<<j<<" "<<k<<" "<<w<<" R\n";
            if(i==nl&&k==nr)ans=min(ans,f[i][j]+w);
        }
        // cout<<"dp "<<i<<" "<<j<<" "<<f[i][j]<<"\n";
    }
    cout<<fixed<<setprecision(10)<<ans<<"\n";
}
signed main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int T;cin>>T;
    for(int i=1;i<=T;++i)cout<<"Case #"<<i<<": ",sol();
}

详细

Subtask #1:

score: 8
Accepted

Test #1:

score: 8
Accepted
time: 1ms
memory: 3932kb

input:

50
4 3
-3 -6 -9
3 2 1
2 2
1 -1
1 1
1000 25
769234 -5735820 -524288 -5403090 -6429140 1574982 1 -9733628 -1407481 4093041 4117720 -3193501 -9765195 -3069520 1122216 -5799108 131072 -8482066 -256 -8021159 -8958386 -7027036 5370579 -3602534 -6834567
425 102 744 155 339 19 999 19 159 198 51 304 369 601 ...

output:

Case #1: 3.0000000000
Case #2: 5.0000000000
Case #3: 51133.9375000000
Case #4: 429262.3961421099
Case #5: 129368.0122795970
Case #6: 7801.8320312500
Case #7: 66656.8125000000
Case #8: 607220.6904235146
Case #9: 5725896.8763440857
Case #10: 129205.2852201258
Case #11: 64298.0000000000
Case #12: 61088...

result:

ok correct! (50 test cases)

Subtask #2:

score: 15
Accepted

Test #2:

score: 15
Accepted
time: 1019ms
memory: 5248kb

input:

50
4 3
-3 -6 -9
3 2 1
2 2
1 -1
1 1
1000 500
-9650379 9806301 -6495789 -1283284 5022779 4725553 9364178 -8123302 -9609729 7847458 -142364 6983908 8147008 -3186924 7339254 -8737645 8757174 7887319 3609962 5780915 -1752801 -1657946 -9511339 5113995 -7887160 -6093170 260267 -3837106 -356098 6676924 6210...

output:

Case #1: 3.0000000000
Case #2: 5.0000000000
Case #3: 205911250.0888889134
Case #4: 36298.0000000000
Case #5: 186002.2500000000
Case #6: 13741948.5000000000
Case #7: 109001.1250000000
Case #8: 38656.8125000000
Case #9: 128881.0561480552
Case #10: 8069407.9870967744
Case #11: 128881.0561480552
Case #1...

result:

ok correct! (50 test cases)

Extra Test:

score: 0
Extra Test Passed