QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#120024#4355. Seesawlmeowdn#1 5ms6116kbC++141.9kb2023-07-06 11:23:242024-07-04 00:21:00

Judging History

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

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

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;
int n,a[N],s[N];
ld ans=inf;

ld avg(int l,int r) {
  return 1.*(s[r]-s[l-1])/(r-l+1);
}
ld work(ld L,int l,int r) {
  if(l==r) return a[l];
  ld pl=avg(l,r-1), pr=avg(l+1,r);
  if(pl<L&&pr<L) return inf;
  else if(pl<L) return max(pr,work(L,l+1,r));
  else if(pr<L) return max(pl,work(L,l,r-1));
  else if(pl<pr) return max(pl,work(L,l,r-1));
  else return max(pr,work(L,l+1,r));
}

signed main() {
  n=read();
  rep(i,1,n) a[i]=read(), s[i]=s[i-1]+a[i];
  rep(l,1,n) rep(r,l+1,n) if(avg(l,r)<=avg(1,n)) chmin(ans,max(avg(1,n),work(avg(l,r),1,n))-avg(l,r));
  printf("%.8Lf\n",ans);
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 1
Accepted

Test #1:

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

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: 6044kb

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: 0ms
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: 33
Accepted
time: 5ms
memory: 6116kb

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:

10402282.13664597

result:

ok found '10402282.136645971', expected '10402282.136645973', error '0.000000000'

Test #5:

score: -33
Wrong Answer
time: 5ms
memory: 5976kb

input:

100
1810572 67741118 89924155 97523910 98515952 100312242 106359350 107613096 108902139 112965058 118556718 124309121 151549997 158865092 164690713 210412893 211326498 214244586 243916452 290578067 311013670 318647903 326203096 332130194 338374082 352170518 358484048 360633563 393895516 401093357 41...

output:

18526994.79822779

result:

wrong answer 1st numbers differ - expected: '18323646.1400000', found: '18526994.7982278', error = '0.0110976'

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%