Trang

Thứ Hai, 3 tháng 1, 2011

3484. Stones

import java.io.*;

public class Main {

    /**
     * http://acm.tju.edu.cn/toj/showp3484.html
     * @author hunglee
     */
    public static void main(String[] args) throws IOException {
        
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(
                new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(System.out);
        
        int t, n, i, sum, max;
        in.nextToken();
        t = (int) in.nval;
        while (t-- > 0) {
            in.nextToken();
            n = (int) in.nval;
            max = -1; sum = 0;
            for (int j = 0; j < n; ++j) {
                in.nextToken();
                i = (int) in.nval;
                sum += i;
                if (max < i)
                    max = i;
            }
            out.println(sum - max);
        }
        out.flush();
    }

}

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

Đăng nhận xét