CSES - HIIT Open 2016 - Results
Submission details
Task:Approximate
Sender:Game of Nolife
Submission time:2016-05-28 11:08:29 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.18 sdetails

Code

#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
ld x[1010101];
ld xx[1010101];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,q;
cin>>n>>q;
for (int i=1;i<=n;i++) {
cin>>x[i];
xx[i]=x[i]*x[i];
x[i]+=x[i-1];
xx[i]+=xx[i-1];
}
cout<<setprecision(6)<<fixed;
for (int i=0;i<q;i++) {
int a,b;
cin>>a>>b;
ld y1=(x[b]-x[a-1])/(b-a+1);
ld y2=(xx[b]-xx[a-1])/(b-a+1);
cout<<y2-y1*y1<<"\n";
}
}

Test details

Test 1

Verdict: ACCEPTED

input
100000 100000
62 64 35 47 57 38 52 4 56 13 7...

correct output
831.753342
833.361649
833.847478
834.425131
831.468120
...

user output
831.753342
833.361649
833.847478
834.425131
831.468120
...