class MaxQueue {
    public Queue queue = new LinkedList();
    public Deque maxQueue = new LinkedList();
    public MaxQueue() {
    }
    public int max_value() {
        if(queue.size() == 0) return -1;
        else return maxQueue.getFirst();
    }
    public void push_back(int value) {
        queue.add(value);
        //maxQueue.size()!=0 当这个值比所有的都大 队列就空了 会报错 getLast()
        while( maxQueue.size()!=0 && value > maxQueue.getLast()) maxQueue.removeLast();
        maxQueue.addLast(value);
    }
    public int pop_front() {
        if(queue.size() == 0) return -1;
        int value = queue.poll();
        if(value == maxQueue.peek()) maxQueue.removeFirst();
        return value;
    }
}