QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#714733 | #9540. Double 11 | ucup-team3691 | WA | 3ms | 12112kb | C++20 | 2.6kb | 2024-11-06 04:10:30 | 2024-11-06 04:10:31 |
Judging History
answer
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
long long v[200005];
//int opt[200005];
long long spar[200005];
long long lz[1800005];
long long mijloc[1800005];
long long drr[1800005];
pair<long double,long double> dp[200005];
long double calc(int i,int j)
{
if(i>=j)
{
return 1e10;
}
return dp[i].first+sqrt((spar[j]-spar[i])*(j-i));
}
void push(int node,int st,int dr)
{
if(lz[node]!=-1)
{
mijloc[node]=lz[node];
drr[node]=lz[node];
if(st!=dr)
{
lz[node*2]=lz[node];
lz[node*2+1]=lz[node];
// drr[node*2]=lz[node];
// drr[node*2+1]=lz[node];
// mijloc[node*2]=lz[node];
// mijloc[node*2+1]=lz[node];
}
}
lz[node]=-1;
}
void update(int node,int st,int dr,int from)
{
push(node,st,dr);
if(dr<st)
{
return;
}
int mij=(st+dr)/2;
if(st==dr)
{
if(calc(from,mij)<=calc(mijloc[node],mij))
{
lz[node]=from;
push(node,st,dr);
}
return;
}
if(calc(from,mij)<=calc(mijloc[node],mij))
{
lz[node*2+1]=from;
push(node*2+1,mij+1,dr);
update(node*2,st,mij,from);
}
else
{
update(node*2+1,mij+1,dr,from);
}
drr[node]=drr[node*2+1];
mijloc[node]=drr[node*2];
}
int qr(int node,int st,int dr,int poz)
{
push(node,st,dr);
if(st==dr)
{
return mijloc[node];
}
int mij=(st+dr)/2;
if(poz<=mij)
{
return qr(node*2,st,mij,poz);
}
else
return qr(node*2+1,mij+1,dr,poz);
}
int n;
int check(long double plm)
{
long double valus;
int from;
lz[1]=0;
push(1,2,3);
for(int i=1; i<=n; i++)
{
from=qr(1,1,n,i);
dp[i].first=calc(from,i)+plm;
dp[i].second=dp[from].second+1;
update(1,1,n,i);
}
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<=90; i++)
{
mij=(st+dr)/2;
val=check(mij);
if(val==m)
{
break;
}
else if(val>m)
{
st=mij;
}
else
{
dr=mij;
}
}
cout<<fixed<<setprecision(9)<<dp[n].first-dp[n].second*mij;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 12020kb
input:
4 2 1 2 3 4
output:
6.191147130
result:
ok found '6.191147130', expected '6.191147130', error '0.000000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 11916kb
input:
10 3 1 2 3 4 5 6 7 8 9 10
output:
22.591625367
result:
ok found '22.591625367', expected '22.591625367', error '0.000000000'
Test #3:
score: 0
Accepted
time: 2ms
memory: 12100kb
input:
1 1 1
output:
1.000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #4:
score: 0
Accepted
time: 2ms
memory: 12112kb
input:
1 1 100000
output:
316.227766017
result:
ok found '316.227766017', expected '316.227766017', error '0.000000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 11920kb
input:
7 1 10 47 53 9 83 33 15
output:
41.833001327
result:
ok found '41.833001327', expected '41.833001327', error '0.000000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 12000kb
input:
8 5 138 1702 119 1931 418 1170 840 1794
output:
233.901654552
result:
ok found '233.901654552', expected '233.901654552', error '0.000000000'
Test #7:
score: 0
Accepted
time: 2ms
memory: 11916kb
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.265287684
result:
ok found '1355.265287684', expected '1355.265287684', error '0.000000000'
Test #8:
score: -100
Wrong Answer
time: 3ms
memory: 12052kb
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.490018280
result:
wrong answer 1st numbers differ - expected: '18791.4753541', found: '18791.4900183', error = '0.0000008'