QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#120067#4355. Seesawlmeowdn#1 668ms5972kbC++142.0kb2023-07-06 13:07:142024-07-04 00:21:04

Judging History

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

  • [2024-07-04 00:21:04]
  • 评测
  • 测评结果:1
  • 用时:668ms
  • 内存:5972kb
  • [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:07:14]
  • 提交

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];
  mt19937 rnd(114);
  rep(t,1,10000) {
    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(rnd()%5==0) swap(pl,pr);
          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: 1
Accepted

Test #1:

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

input:

2
925278587 966813970

output:

20767691.50000000

result:

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

Test #2:

score: 0
Accepted
time: 24ms
memory: 5764kb

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: 0
Accepted
time: 25ms
memory: 3932kb

input:

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

output:

37041534.65294111

result:

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

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #4:

score: 0
Wrong Answer
time: 668ms
memory: 5972kb

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:

13509583.46945781

result:

wrong answer 1st numbers differ - expected: '10402282.1366460', found: '13509583.4694578', error = '0.2987134'

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%