# HIIT Open 2016

 Start: 2016-05-28 11:00:00 End: 2016-05-28 16:00:00

CSES - HIIT Open 2016 - Results
History
2016-05-28 11:10:36

## Test results

 test verdict time (s) #1 ACCEPTED 0.16 / 1.00 details

## Code

```#include<bits/stdc++.h>

using namespace std;

int main(void) {
cin.tie(0);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(6);

int64_t n, q;
cin >> n >> q;

vector<int64_t> s(n+1), s2(n+1);

for(int64_t i=0;i<n;i++) {
int64_t x;
cin >> x;
if(i != 0) {
s[i] = s[i-1]+x;
s2[i] = s2[i-1]+x*x;
}
else {
s[i]=x;
s2[i]=x*x;
}
}

for(int64_t i=0;i<q;i++) {
int64_t a,b;
cin >> a >> b;
a--;
b--;
int64_t k=b-a+1;
int64_t mys, mys2;
if(a > 0) {
mys=s[b] - s[a-1];
mys2=s2[b] - s2[a-1];
} else {
mys=s[b];
mys2=s2[b];
}
cout << (double)1/(double)k * mys2 - (double)1/(double)(k*k) * (double) mys * (double) mys << '\n';
}

return 0;
}

```

## Test details

### Test 1

Verdict: ACCEPTED

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

correct output
```831.753342 833.361649 833.847478 834.425131 831.468120 836.550284 840.319891 843.709808 830.097515 832.352323 828.549331 811.748878 833.912525 830.245034 831.485429 815.101051 834.579010 848.833782 839.942329 822.449380 ...```
view   save

user output
```831.753342 833.361649 833.847478 834.425131 831.468120 836.550284 840.319891 843.709808 830.097515 832.352323 828.549331 811.748878 833.912525 830.245034 831.485429 815.101051 834.579010 848.833782 839.942329 822.449380 ...```
view   save