Simple Question -Short code -Gives Runtime error sigsegv everytime!!!

There is this very easy looking question. My solution works fine with tests cases on codechef compiler & g++ & codeblocks. But judge give a Runtime error every f*ing time!!! Someone please help :frowning:
Question : Girls and Security Patrol

#include<iostream>
#include<math.h>
#include<stdio.h>

using namespace std;

class dist
{
    long u=0,v=0;
    double x=0;
    double t=0;

public:
    void entuv()
        scanf("%d%d%lf",&u,&v,&x);


    void calcT()
        t=(double)x/(u+v);
    
    double retT()
        return t;

};

int main()
{
    int n;
    dist k;
    double ans[100];
    scanf("%d",&n);
    for(int i=0; i<n ;i++)
    {
        k.entuv();
        k.calcT();
        ans[i]=k.retT();
    }

    for(int i=0;i<n;i++)
    {
        printf("%lf\n",ans[i]);
    }

    return 0;
}

Its not allowed to share code or anything related to an on going contest.

1 Like