@@ -0,0 +1,1481 @@
+/* paiza POH! Vol.1%0A * result:%0A * http://paiza.jp/poh/ec-campaign/result/390c4a5bb8b4f46cebae48f70ee21c2e%0A * author: Leonardone @ NEETSDKASU%0A */%0Aimport java.io.BufferedReader;%0Aimport java.io.InputStreamReader;%0Aimport java.util.Arrays;%0Aimport java.io.PrintStream;%0A%0Apublic class Main %7B%0A    static BufferedReader r;%0A    static PrintStream out;%0A    static int n;%0A    static int d;%0A    static int%5B%5D p;%0A    static int m, f, e, tmp, sum, ci, cp;%0A    static String%5B%5D str;%0A    static %7B%0A        r = new BufferedReader(%0A            new InputStreamReader(System.in));%0A        out = System.out;%0A        p = new int%5B200000%5D;%0A    %7D%0A    public static void main (String%5B%5D args) throws Exception %7B%0A        // Java sun-jdk-1.7.0_10%0A        str = r.readLine().split(%22 %22);%0A        n = Integer.parseInt(str%5B0%5D);%0A        d = Integer.parseInt(str%5B1%5D);%0A        for (int i = 0; i %3C n; ++i) %7B%0A            p%5Bi%5D = Integer.parseInt(r.readLine());%0A        %7D%0A        Arrays.sort(p, 0, n);%0A        ci = (n - 1) %3E%3E 1;%0A        cp = p%5Bci%5D;%0A        for (int i = 0; i %3C d; ++i) %7B%0A            m = Integer.parseInt(r.readLine());%0A            f = m %3C cp ? ci : n - 1;%0A            e = m - p%5Bf%5D %3E cp ? ci : 0 ;%0A            tmp = 0;%0A            while (f != e) %7B%0A                sum = p%5Bf%5D + p%5Be%5D;%0A                if (sum %3E m)%0A                    --f;%0A                else %7B%0A                    if (sum %3E tmp) tmp = sum;%0A                    ++e;%0A                %7D%0A            %7D%0A            out.println(tmp);%0A        %7D%0A    %7D%0A%7D%0A

Create answer.java