0

When I am submitting this program on codechef. I am getting TLF error... So, please help.....what should I do? And I want to know when TLF occurs and What is the normal cause of them. time limit for this program is 1sec.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Query {

    public static void main(String[] args) throws IOException {
        int M = 1000000007;
        BufferedReader scan = new BufferedReader (new InputStreamReader(System.in));
        String[] buff = scan.readLine().split(" ");
        int n = Integer.parseInt(buff[0]);
        int q = Integer.parseInt(buff[1]);
        int s[] = new int[n];
        buff = scan.readLine().split(" ");
        for(int i=0;i<n;i++){
            s[i] = Integer.parseInt(buff[i]);
        }
        for(int p=0;p<q;p++){
            buff = scan.readLine().split(" ");
            int type = Integer.parseInt(buff[0]);
            int x = Integer.parseInt(buff[1])-1;
            int y = Integer.parseInt(buff[2])-1;
            if(type == 4){
                int sum = 0;
                    for (int i = x; i <= y; i++){
                        sum += s[i];
                    }
                    sum %= M;
                    System.out.println(sum);
            }
            else{
                int v = Integer.parseInt(buff[3]) ;
                switch(type){
                    case 1:{
                        for (int i = x; i <= y; i++){   
                            s[i]  += v;
                            s[i] %= M;
                        }
                        break;
                    }
                    case 2:{
                        for (int i = x; i <= y; i++){
                            s[i] *= v;
                            s[i] %= M;
                        }
                        break;
                    }
                    case 3:{
                        for (int i = x; i <= y; i++)    
                            s[i] = v ;
                        break;
                    }
                }
            }
        }
    }
}
galath
  • 5,717
  • 10
  • 29
  • 41
railee
  • 1
  • 1

0 Answers0