QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#708023 | #9540. Double 11 | ucup-team3691 | WA | 1ms | 6012kb | C++20 | 1.3kb | 2024-11-03 18:55:17 | 2024-11-03 18:55:18 |
Judging History
answer
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
int v[200005];
//int opt[200005];
long long spar[200005];
pair<long double,int> dp[200005];
int n;
int check(long double plm)
{
long double valus;
dp[0]={0,0};
int opt=0;
for(int i=1;i<=n;i++)
{
dp[i]={1e9,0};
while (opt+1<i && dp[opt].first+sqrtl((spar[i]-spar[opt])*(i-opt))>=dp[opt+1].first+sqrtl((spar[i]-spar[opt+1])*(i-opt-1)))
{
opt++;
}
dp[i].first=dp[opt].first+sqrtl((spar[i]-spar[opt])*(i-opt));
dp[i].second=dp[opt].second+1;
dp[i].first+=plm;
}
return dp[n].second;
}
int main()
{
int i,j,k,l,m,val;
long double st=-1e9,dr=1e9,mij;
cin>>n>>m;
for(i=1;i<=n;i++)
{
cin>>v[i];
}
sort(v+1,v+n+1);
for(i=1;i<=n;i++)
{
spar[i]=spar[i-1]+v[i];
}
for(i=1;i<=65;i++)
{
mij=(st+dr)/2;
val=check(mij);
if(val==m)
{
break;
}
else if(val>m)
{
st=mij;
}
else
{
dr=mij;
}
}
cout<<fixed<<setprecision(12)<<dp[n].first-m*mij;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3912kb
input:
4 2 1 2 3 4
output:
6.191147129557
result:
ok found '6.191147130', expected '6.191147130', error '0.000000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5980kb
input:
10 3 1 2 3 4 5 6 7 8 9 10
output:
22.591625366514
result:
ok found '22.591625367', expected '22.591625367', error '0.000000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3984kb
input:
1 1 1
output:
1.000000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
1 1 100000
output:
316.227766016838
result:
ok found '316.227766017', expected '316.227766017', error '0.000000000'
Test #5:
score: 0
Accepted
time: 1ms
memory: 6012kb
input:
7 1 10 47 53 9 83 33 15
output:
41.833001326711
result:
ok found '41.833001327', expected '41.833001327', error '0.000000000'
Test #6:
score: 0
Accepted
time: 1ms
memory: 5788kb
input:
8 5 138 1702 119 1931 418 1170 840 1794
output:
233.901654551944
result:
ok found '233.901654552', expected '233.901654552', error '0.000000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
58 1 888 251 792 847 685 3 182 461 102 348 555 956 771 901 712 878 580 631 342 333 285 899 525 725 537 718 929 653 84 788 104 355 624 803 253 853 201 995 536 184 65 205 540 652 549 777 248 405 677 950 431 580 600 846 328 429 134 983
output:
1355.265287683549
result:
ok found '1355.265287684', expected '1355.265287684', error '0.000000000'
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3932kb
input:
88 30 67117 31903 93080 85196 16438 97116 11907 72959 83651 41273 52873 81892 81468 51323 99992 58869 54258 7183 87358 90990 80596 41252 90769 82705 61434 8524 13575 10787 53950 96768 12062 34637 27806 70937 69653 28380 90236 3352 27537 3873 91006 89790 25369 91825 82734 5588 4539 74118 47098 84741 ...
output:
18791.618538150083
result:
wrong answer 1st numbers differ - expected: '18791.4753541', found: '18791.6185382', error = '0.0000076'