Code Submission Evaluation System Login

# 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:34:39
2016-05-28 11:31:34
 Task: Approximate Sender: Barely Div 1 Submission time: 2016-05-28 11:34:39 Language: C++ Status: READY Result: ACCEPTED

## Test results

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

## Code

```#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>

using namespace std;

int main() {
int n, q;
cin >> n >> q;
vector<int> s(n+1), cum(n+1), cum2(n+1);
for(int i=1; i<=n; i++) {
cin >> s[i];
cum[i] = s[i];
cum2[i] = s[i]*s[i];
if(i) {
cum[i] += cum[i-1];
cum2[i] += cum2[i-1];
}
//cout << cum[i] << endl;
//cout << cum2[i] << endl;
}

for(int i=0; i<q; i++) {
int a, b;
cin >> a >> b;
double k = b-a+1;
double s = (double)(cum[b]-cum[a-1]);
double s2 = (double)(cum2[b]-cum2[a-1]);
double c = s/k;
double ans = (k*c*c - 2*s*c + s2)/k;
printf("%.06f\n", ans);
//cout << setprecision(6) << ans << endl;
}
}
```

## 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