QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#39836#4355. SeesawZeinDaner#0 0ms5936kbC++1.2kb2022-07-14 04:20:202024-05-26 01:00:53

Judging History

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

  • [2024-05-26 01:00:53]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:5936kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-14 04:20:20]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<double,double> dd;
const int MAX_N=2e5+10;
const int MAX=1e9+10;
ll val[MAX_N];
ll prs[MAX_N];

dd minmax(int l,int r){
  if(l==r) return dd(val[l],val[l]);
  double c=prs[r]-prs[l-1];
  c/=(double)(r-l+1);
  dd tl=minmax(l+1,r);
  tl.first=min(tl.first,c); tl.second=max(tl.second,c);
  dd tr=minmax(l,r-1);
  tr.first=min(tr.first,c); tr.second=max(tr.second,c);
  if(tl.second-tl.first<tr.second-tr.first) return tl;
  return tr;
}
int main(){
  int n; cin>>n;
  for(int i=1;i<=n;i++){
    cin>>val[i];
  }
  for(int i=1;i<=n;i++){
    prs[i]=prs[i-1]+val[i];
  }
  double pr=prs[n]/(double)n;
  double mi=min(pr,(double)val[(n+1)/2]),ma=max(pr,(double)val[(n+1)/2]);
  int l=1,r=n;
  ll s=prs[n];
  for(int i=1;i<n;i++){
    double dl=(s-val[l])/(double)(n-i);
    double dr=(s-val[r])/(double)(n-i);
    if(min(abs(dl-ma),abs(dl-mi))>min(abs(dr-ma),abs(dr-mi))){
      mi=min(mi,dr); ma=max(ma,dr);
      s-=val[r];
      r--;
    }
    else{
      mi=min(mi,dl); ma=max(ma,dl);
      s-=val[l];
      l++;
    }
  }
  printf("%.12f\n",ma-mi);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 1
Accepted
time: 0ms
memory: 3856kb

input:

2
925278587 966813970

output:

20767691.500000000000

result:

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

Test #2:

score: -1
Wrong Answer
time: 0ms
memory: 5936kb

input:

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

output:

370649846.000000000000

result:

wrong answer 1st numbers differ - expected: '52991294.1666667', found: '370649846.0000000', error = '5.9945423'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%