Code Submission Evaluation System Login

HIIT Open 2016

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

Tasks | Messages | Scoreboard | Statistics


CSES - HIIT Open 2016 - Results
History
2016-05-28 12:48:27
Task:Approximate
Sender:zah
Submission time:2016-05-28 12:48:27
Language:C++
Status:READY
Result:ACCEPTED

Test results

testverdicttime (s)
#1ACCEPTED0.31 / 1.00details

Code

#include <iostream>

using namespace std;

int main(){
    int n, q;
    cin >> n >> q;
    double t[100001]={}, y[100001]={};
    for (int i=1; i<=n; ++i){
        double a;
        cin >> a;
        t[i]=t[i-1]+a;
        y[i]=y[i-1]+a*a;
    }
     for (int i=0; i<q; ++i){
        int a, b;
        cin >> a >> b;
        double joku=t[b]-t[a-1];
        double k=b-a + 1;
        double x=joku/k;
        double vastaus=(y[b]-y[a-1]-2*x*joku+k*x*x)/k;
        std::cout.unsetf ( std::ios::floatfield );
        std::cout.setf( std::ios::fixed, std:: ios::floatfield );
        std::cout.precision(6);
        cout << vastaus << "\n";
    }
}

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