QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#40602#4355. SeesawZeinDaner1 9ms5164kbC++14757b2022-07-22 20:16:362022-07-22 20:16:39

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-22 20:16:39]
  • 评测
  • 测评结果:1
  • 用时:9ms
  • 内存:5164kb
  • [2022-07-22 20:16:36]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N=2e5+10;
int val[MAX_N];
ll pre[MAX_N];
map<tuple<int,int,double,double>,double >dp;
double seesaw(int l,int r,double mi,double  ma){
  if(l==r) return max(ma,(double)val[r])-min(mi,(double)val[l]);
  auto sta=make_tuple(l,r,mi,ma);
  if(dp.find(sta)!=dp.end()) return dp[sta];
  double ans;
  double m=(r-l)+1;
  ll sum=pre[r]-pre[l-1];
  double ba=sum/m;
  ans=min(seesaw(l+1,r,min(mi,ba),max(ma,ba)),seesaw(l,r-1,min(mi,ba),max(ma,ba)));
  return dp[sta]=ans;
}
int main(){
  int n; scanf("%d",&n);
  for(int i=1;i<=n;i++){
    scanf("%d",&val[i]);
  }
  for(int i=1;i<=n;i++) pre[i]=pre[i-1]+val[i];
  printf("%.12f\n",seesaw(1,n,1e9+1,-1));
}

详细

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 3ms
memory: 3908kb

input:

2
925278587 966813970

output:

20767691.500000000000

result:

ok found '20767691.500000000', expected '20767691.500000000', error '0.000000000'

Test #2:

score: 0
Accepted
time: 9ms
memory: 4832kb

input:

20
7902238 121690240 160345001 255257832 269315023 288280211 296247186 353929891 494812700 530994847 567379029 567478415 612943598 644028258 654380821 696407711 708542915 738196686 743020754 760907139

output:

52991294.166666686535

result:

ok found '52991294.166666687', expected '52991294.166666687', error '0.000000000'

Test #3:

score: 0
Accepted
time: 9ms
memory: 5164kb

input:

20
37698309 122861191 172244451 227579326 314637638 425599056 429200117 531049382 548293537 557767688 600249369 625965962 703410128 707452380 747227710 753853272 821738507 858449772 859150731 988518805

output:

37041534.652941107750

result:

ok found '37041534.652941108', expected '37041534.652941108', error '0.000000000'

Subtask #2:

score: 0
Time Limit Exceeded

Dependency #1:

100%
Accepted

Test #4:

score: 0
Time Limit Exceeded

input:

100
3062543 14271669 41756258 53160546 58687738 65412641 67125846 67682424 88351830 97353987 99930389 104312394 110237749 130302887 144473978 192578518 199299154 202189413 203221174 206103152 207626225 248318304 251935772 253594311 255555599 258718911 280683793 291873353 296119011 303038714 30679761...

output:


result:


Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%