Submission #332001

# Submission time Handle Problem Language Result Execution time Memory
332001 2020-12-01T06:06:30 Z anishrajeev Temperature (POI11_tem) Java 11
0 / 100
1000 ms 45124 KB
import java.io.*;
import java.util.*;

public class tem {
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader bf = new BufferedReader(new FileReader("tester.in"));
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
        int[] min = new int[1000000];
        int[] max = new int[1000000];
        int N = Integer.parseInt(bf.readLine());
        for(int i = 0; i < N; i++){
            StringTokenizer stk = new StringTokenizer(bf.readLine());
            min[i] = Integer.parseInt(stk.nextToken());
            max[i] = Integer.parseInt(stk.nextToken());
        }
        TreeSet<Integer> set = new TreeSet<>();
        HashMap<Integer, Integer> map = new HashMap<>();
        int right = 0;
        int left = 0;
        int answer = 0;
        set.add(min[0]);
        map.put(min[0], 1);
        int counter = 1;
        while(right < N-1){
            int highestmin = -1;
            if(set.size()!=0)highestmin = set.last();
            if(min[right+1]>=highestmin||highestmin<=max[right+1]){
                right++;
                if(set.contains(min[right]))map.replace(min[right], map.get(min[right])+1);
                else{
                    set.add(min[right]);
                    map.put(min[right], 1);
                }
                counter++;
            }
            else{
                left++;
                map.replace(min[left-1], map.get(min[left-1])-1);
                if(map.get(min[left-1])==0){
                    map.remove(min[left-1]);
                    set.remove(min[left-1]);
                }
                counter--;
            }
            answer = Math.max(answer, counter);
        }
        System.out.println(answer);
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 85 ms 17752 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 85 ms 17388 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 315 ms 22224 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 383 ms 25848 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 544 ms 26084 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 538 ms 26100 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 567 ms 25568 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 45124 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 843 ms 31556 KB Output is correct
2 Runtime error 851 ms 33684 KB Memory limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 441 ms 27964 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 521 ms 26336 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 531 ms 24328 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -