QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#392282 | #8309. Mountain | PlentyOfPenalty | WA | 16ms | 61288kb | C++20 | 1.7kb | 2024-04-17 13:56:40 | 2024-04-17 13:56:40 |
Judging History
answer
#include<bits/stdc++.h>
#define pi pair<int,int>
#define f first
#define s second
using namespace std;
const int N=200;
const double FI=-1e9;
int n,W,w2,H,h[N+10],sz;
double f[N+10][N+10][(1<<9)+10];
double ans,tmp;
pi a[15];
double Area(int l1,int l2,int lm){
if(l1>l2)swap(l1,l2);
if(lm<=0)return 0;
if(lm<=l1)return lm;
lm=min(lm,l2);
return l1+(1.0+(l2-lm)/(1.0*l2-l1))*(lm-l1)/2.0;
}
double Calc(int x,int ms){
if(x<0)return 0;
double ret=0;
sz=0;
for(int i=0;i<=w2;++i)if(ms&(1<<i))a[++sz]=(pi){h[x+W-i]-H,h[x+W-i]+H};
int tl=0,tr=0;
sort(a+1,a+sz+1);
for(int i=1;i<=sz;++i){
if(a[i].f>tr){
ret+=Area(h[x],h[x+1],tr)-Area(h[x],h[x+1],tl);
tl=a[i].f,tr=a[i].s;
}else tr=max(tr,a[i].s);
}
ret+=Area(h[x],h[x+1],tr)-Area(h[x],h[x+1],tl);
return ret;
}
void Upd(double&x,double y){x=max(x,y);}
int main(){
cin.sync_with_stdio(0),cin.tie(0);
cin>>n>>W>>H;
w2=(W<<1)-1;
for(int i=1;i<=n;++i)cin>>h[i];
for(int i=1;i<(1<<w2);++i)f[0][0][i]=FI;
for(int i=1;i<=n;++i){
for(int j=0;j<=i;++j)for(int k=0;k<(1<<w2);++k)f[i][j][k]=FI;
for(int j=0;j<i;++j)for(int k=0;k<(1<<w2);++k)if(f[i-1][j][k]>=0){
Upd(f[i][j][((k<<1)&((1<<w2)-1))],f[i-1][j][k]+Calc(i-W,k<<1));
Upd(f[i][j+1][((k<<1|1)&((1<<w2)-1))],f[i-1][j][k]+Calc(i-W,k<<1|1));
}
}
for(int i=1;i<=n;++i){
ans=0;
for(int j=0;j<(1<<w2);++j)if(f[n][i][j]>=0){
tmp=f[n][i][j];
for(int k=n-W+1,t=(j<<1);k<=n;++k,t=((t<<1)&((1<<w2+1)-1)))tmp+=Calc(k,t);
ans=max(ans,tmp);
}
cout<<fixed<<setprecision(10)<<ans<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5932kb
input:
3 1 2 2 1 3
output:
3.5000000000 4.5000000000 5.1666666667
result:
ok 3 numbers
Test #2:
score: 0
Accepted
time: 1ms
memory: 5968kb
input:
2 3 78 55 51
output:
106.0000000000 106.0000000000
result:
ok 2 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 34588kb
input:
36 3 61 63 83 12 81 1 58 56 13 1 82 54 16 66 43 9 92 98 34 95 37 36 10 50 45 27 74 83 94 82 48 47 62 22 10 92 49
output:
385.5000000000 763.1796875000 1028.6796875000 1294.0789379409 1559.0109444729 1721.0109444729 1820.3747125888 1823.7332589286 1825.0000000000 1825.0000000000 1825.0000000000 1825.0000000000 1825.0000000000 1825.0000000000 1825.0000000000 1825.0000000000 1825.0000000000 1825.0000000000 1825.000000000...
result:
ok 36 numbers
Test #4:
score: 0
Accepted
time: 3ms
memory: 36608kb
input:
37 2 9 51 64 99 52 2 7 33 73 4 39 1 22 41 51 97 72 71 46 11 10 37 79 97 79 70 19 58 13 43 88 38 55 54 9 31 74 62
output:
69.6346153846 138.8937062937 207.5235755748 268.6092898605 317.5915975528 363.6906461786 408.3734516084 452.2230756686 491.3926408860 527.9283551717 564.4197085551 600.4197085551 636.3680064275 672.3106151231 707.8477579803 736.8277328967 760.4206651334 782.5022440808 803.6457081330 823.9471897535 8...
result:
ok 37 numbers
Test #5:
score: -100
Wrong Answer
time: 16ms
memory: 61288kb
input:
66 4 90 54 54 42 52 31 76 14 66 59 63 85 49 15 80 54 35 39 87 34 72 28 86 24 76 12 45 34 28 60 24 6 48 35 86 65 59 87 50 7 12 25 31 81 7 29 62 37 90 75 98 49 15 100 78 36 98 80 48 36 15 28 16 35 76 50 71
output:
545.0000000000 1000.5000000000 1437.0000000000 1869.5000000000 2299.0000000000 2639.5000000000 2955.0000000000 3182.5000000000 3218.0000000000 3218.0000000000 3218.0000000000 3218.0000000000 3218.0000000000 3218.0000000000 3218.0000000000 3218.0000000000 3218.0000000000 3218.0000000000 3218.00000000...
result:
wrong answer 6th numbers differ - expected: '2665.0000000', found: '2639.5000000', error = '0.0095685'