Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Java by Gimran ( 6 years ago )
import java.io.*;
import java.util.*;

public class gimran {

    public static void main(String[] args) throws IOException {
        int []m=new int[2];

        int n = m[0];
        long h = m[1];
        long[] a = new long[n];
        long max = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] > max) {
                max = a[i];
            }
        }
        max--;
        int bool = 1;
        while (bool != 0) {
            long sum = 0L;
            for (int i = 0; i < n; i++) {
                if (a[i] >= max)
                    sum = sum + a[i] - max;


            }
            if (sum >= h) {
                bool = 0;
                out.println(max);
            }
        }


        out.close();
    }

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer in = new StringTokenizer("");


    public static String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

    public static int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public static long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
}

 

Revise this Paste

Your Name: Code Language: