Trang

Chủ Nhật, 2 tháng 1, 2011

2196. Nuanran's Idol II

import java.io.*;
import java.util.PriorityQueue;

public class Main {

    /**
     * http://acm.tju.edu.cn/toj/showp2196.html
     * @author hunglee
     */
    public static void main(String[] args) throws IOException {
        
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(
                new InputStreamReader(System.in)));
        
        int n;
        PriorityQueue<Integer> a = new PriorityQueue<Integer>();
        do {
            in.nextToken();
            n = (int) in.nval;
            if (n == 0)
                break;
            
            a.clear();
            for (int i = 0; i < n; ++i) {
                in.nextToken();
                if (in.sval.charAt(0) == 'B') {
                    in.nextToken();
                    a.add((int) in.nval);
                } else
                    System.out.println(a.remove());
            }
        } while (true);
    }

}

Không có nhận xét nào:

Đăng nhận xét