結果

問題 No.2227 King Kraken's Attack
ユーザー norikame
提出日時 2023-01-19 02:18:25
言語 Java
(openjdk 23)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 897 bytes
コンパイル時間 3,371 ms
コンパイル使用メモリ 77,500 KB
実行使用メモリ 41,456 KB
最終ジャッジ日時 2024-10-02 11:02:16
合計ジャッジ時間 10,329 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

// 

import java.util.*;

public class Main_sol1 {
    private static final int INF = (int)(1e9);
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt(), w = sc.nextInt(), la = sc.nextInt(), lb = sc.nextInt();
        long ka = sc.nextLong(), kb = sc.nextLong();
        sc.close();
        int amx = (h+la-1) / la, bmx = (w+lb-1) / lb, bcnt = bmx + 1, res = INF;
        for (int acnt=0; acnt<=amx; ++acnt) {
            int alen = Math.min(h, acnt*la);
            long adda = acnt * ka;
            while (bcnt > 0) {
                int blen = Math.min(w, (bcnt-1)*lb);
                long addb = (bcnt-1) * kb;
                if ((long)alen*blen+adda+addb < (long)h*w) break;
                --bcnt;
            }
            if (bcnt <= bmx) res = Math.min(res, acnt+bcnt);
        }
        System.out.println(res);
    }
}
0