java中的时间限制超过错误

时间:2015-07-04 12:52:17

标签: java tlf

当我在codechef上提交此程序时。我收到TLF错误... 所以,请帮助.....我该怎么办? 我想知道TLF何时发生以及它们的正常原因是什么。 该程序的时间限制为1秒。

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;
                    }
                }
            }
        }
    }
}

0 个答案:

没有答案
相关问题