QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#120063#4355. Seesawlmeowdn#0 1ms6100kbC++141.9kb2023-07-06 13:03:292024-07-04 00:21:03

Judging History

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

  • [2024-07-04 00:21:03]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:6100kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-06 13:03:29]
  • 提交

answer

#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x)  {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x)  {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x)  {return (x==0?-1:__builtin_ctzll(x));}

#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii; 
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
  int x=0,w=1; char c=getchar(); 
  while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
  while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
  return x*w;
}

const int N=2e5+5;
const ld inf=1e9,eps=1e-9;
int n,a[N],s[N];
ld ans=inf,b[N];

ld avg(int l,int r) {
  return 1.*(s[r]-s[l-1])/(r-l+1);
}

signed main() {
  n=read();
  rep(i,1,n) a[i]=read(), s[i]=s[i-1]+a[i];
  rep(x,1,n) {
    int l=x, r=x; ld mn=a[x],mx=a[x];
    rep(i,2,n) {
      ld res=0;
      if(l==1) res=avg(l,++r);
      else if(r==n) res=avg(--l,r);
      else {
        ld pl=fabs(a[x]-avg(l-1,r));
        ld pr=fabs(a[x]-avg(l,r+1));
        if(pl<pr) res=avg(--l,r);
        else res=avg(l,++r);
      }
      chmin(mn,res), chmax(mx,res);
    }
    chmin(ans,mx-mn);
  }
  printf("%.8Lf\n",ans);
  return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 1
Accepted
time: 1ms
memory: 6100kb

input:

2
925278587 966813970

output:

20767691.50000000

result:

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

Test #2:

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

input:

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

output:

52991294.16666669

result:

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

Test #3:

score: -1
Wrong Answer
time: 1ms
memory: 5796kb

input:

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

output:

40632608.97549021

result:

wrong answer 1st numbers differ - expected: '37041534.6529411', found: '40632608.9754902', error = '0.0969472'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%