QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#138511 | #4355. Seesaw | Antekb# | 0 | 0ms | 3932kb | C++14 | 1.1kb | 2023-08-11 20:51:57 | 2024-07-04 01:37:31 |
answer
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define pp pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;
using vii = vector<pii>;
using ll = long long;
using ld = long double;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main(){
int n;
cin>>n;
vector<ll> V(n+1);
for(int i=1; i<=n; i++){
cin>>V[i];
V[i]+=V[i-1];
}
priority_queue<pair<ld, pii> > Q;
ld ans=1e9;
ld M=V[n]/ld(n);
while(true){
vi gdzie(n);
ld mm=M;
for(int i=0; i<n; i++){
int l=1, r=n-i-1;
while(l<r){
int m=(l+r+1)>>1;
if((V[m+i]-V[m-1])/ld(i+1)>M)r=m-1;
else l=m;
}
gdzie[i]=l;
mm=min(mm, (V[l+i]-V[l-1])/ld(i+1));
}
ans=min(ans, M-mm);
bool czy=1;
for(int i=0; i<n; i++){
int l=gdzie[i];
if(mm==(V[l+i]-V[l-1])/ld(i+1)){
if(gdzie[i]==n-i-1){
czy=0;
}
else{
M=max(M, (V[l+i+1]-V[l])/ld(i+1));
}
}
}
if(!czy)break;
}
cout<<fixed<<setprecision(10)<<ans;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 1
Accepted
time: 0ms
memory: 3860kb
input:
2 925278587 966813970
output:
20767691.5000000000
result:
ok found '20767691.500000000', expected '20767691.500000000', error '0.000000000'
Test #2:
score: -1
Wrong Answer
time: 0ms
memory: 3932kb
input:
20 7902238 121690240 160345001 255257832 269315023 288280211 296247186 353929891 494812700 530994847 567379029 567478415 612943598 644028258 654380821 696407711 708542915 738196686 743020754 760907139
output:
54422017.9210526316
result:
wrong answer 1st numbers differ - expected: '52991294.1666667', found: '54422017.9210526', error = '0.0269992'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%