Sort by

recency

|

3 Discussions

|

  • + 1 comment

    I'm stuck.. Getting timeout after 10th test ;/

    import sys
    
    def check(l, r, x, y, p):
        for i in range(l-1,r): 
            if (y-(p[i][0]*x)-p[i][1]) < 0:
                return 'YES'
        return 'NO'
    
    tests = int(input())
    lines = []
    queries = []
    
    i = 0;
    for i in range(0,tests): 
        l0,l1 = map(int,input().split())
        lines.append([ l0, l1 ] )
        
    queries_n = int(input())
    
    for i in range(0,queries_n):
        q0,q1,q2,q3 = map(int,input().split())
        sys.stdout.write(check(q0,q1,q2,q3,lines) + '\n')
    
  • + 0 comments

    any hits to optimize code?

  • + 1 comment

    include

    include

    include

    include

    struct line { long m,c; }; struct query { long l,r,x,y; }; int check(long,long,long,long,struct line []); int main() { int test,querysize; scanf("%d",&test); struct line l[test]; for(int i=0;i

    for(int i=0;i<querysize;i++)
    { int flag=check(q[i].l,q[i].r,q[i].x,q[i].y,l);
        if(flag==0)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
    

    } int check(long l,long r,long x,long y,struct line p[]) {

    for(long i=l-1;i<=r-1;i++)
    { long e= y-((p[i].m)*x)-(p[i].c);
    
        if(e<0)
            return 0;
    
    }
    return 1;
    

    }

No more comments