Submission #1532456


Source Code Expand

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    private static int n;
    private static long a, b;
    private static long[] enemy;

    private static boolean C(long k) {
        long cnt = 0;
        for (long hp : enemy) {
            hp -= b * k;
            if (hp > 0) {
                cnt += Math.ceil((double) hp / (a - b));
            }
        }

        if (cnt > k) return false;
        else return true;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        n = Integer.parseInt(str[0]);
        a = Long.parseLong(str[1]);
        b = Long.parseLong(str[2]);

        enemy = new long[n];
        for (int i = 0; i < n; i++) enemy[i] = Long.parseLong(br.readLine());

        long l = 0, r = (long) 1e9+1, med = -1;
        while (r - l > 0) {
            med = (r + l) / 2;
            if (C(med)) {
                r = med;
            } else {
                l = med + 1;
            }
        }
        System.out.println(l);
    }
}

Submission Info

Submission Time
Task D - Widespread
User kengo0o0
Language Java8 (OpenJDK 1.8.0)
Score 400
Code Size 1256 Byte
Status AC
Exec Time 190 ms
Memory 32468 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 13
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13
Case Name Status Exec Time Memory
a01 AC 70 ms 20308 KB
a02 AC 69 ms 18772 KB
a03 AC 68 ms 19268 KB
b04 AC 68 ms 18644 KB
b05 AC 190 ms 27952 KB
b06 AC 184 ms 28676 KB
b07 AC 173 ms 30804 KB
b08 AC 162 ms 28656 KB
b09 AC 161 ms 32468 KB
b10 AC 177 ms 28244 KB
b11 AC 176 ms 26580 KB
b12 AC 167 ms 27980 KB
b13 AC 186 ms 28616 KB