Task: | Approximate |
Sender: | LTR |
Submission time: | 2016-05-28 11:09:00 +0300 |
Language: | C++ |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | TIME LIMIT EXCEEDED | -- | details |
Code
#include <iostream> #include <vector> #include <cstdio> int main() { int n, q; std::cin >> n >> q; std::vector<int> c; c.reserve(n); for (int i = 0; i < n; ++i) { int x; std::cin >> x; c.push_back(x); } for (int i = 0; i < q; ++i) { int a, b; std::cin >> a >> b; double d = 0.0; for (int j = (a - 1); j < b; ++j) { d += c[j]; } d /= (b - a + 1); double err = 0.0; for (int j = (a - 1); j < b; ++j) { double diff = d - c[j]; err += diff * diff; } err /= (b - a + 1); printf("%.6f\n", err); } }