結果

問題 No.1071 ベホマラー
ユーザー bluemeganebluemegane
提出日時 2020-06-06 17:12:49
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,123 bytes
コンパイル時間 1,079 ms
コンパイル使用メモリ 63,420 KB
実行使用メモリ 33,708 KB
最終ジャッジ日時 2023-08-25 01:28:38
合計ジャッジ時間 5,874 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
20,804 KB
testcase_01 AC 55 ms
22,856 KB
testcase_02 AC 54 ms
18,876 KB
testcase_03 AC 53 ms
20,716 KB
testcase_04 AC 77 ms
20,660 KB
testcase_05 AC 54 ms
22,696 KB
testcase_06 AC 53 ms
20,792 KB
testcase_07 AC 54 ms
18,840 KB
testcase_08 AC 53 ms
20,900 KB
testcase_09 AC 55 ms
22,708 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;

public class Hello
{
    static int n, k, x, y, azero;
    static long ans;

    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        n = int.Parse(line[0]);
        k = int.Parse(line[1]);
        x = int.Parse(line[2]);
        y = int.Parse(line[3]);
        var a = new int[n];
        line = Console.ReadLine().Trim().Split(' ');
        azero = 0;
        for (int i = 0; i < n; i++)
        {
            a[i] = (int.Parse(line[i]) + k - 2) / k;
            if (a[i] == 0) azero++;
        }
        ans = 0L;
        getAns(a);
        Console.WriteLine(ans);
    }
    static void getAns(int[] a)
    {
        while (azero < n)
        {
            if (check(a)) { ans += (long)(n - azero) * x; }
            else ans += y;
            dec(a);
        }
    }
    static void dec(int[] a)
    {
        for (int i = 0; i < n; i++)
        {
            if (a[i] > 1) a[i]--;
            else if (a[i] == 1) { a[i] = 0; azero++; }
        }
    }
    static bool check(int[] a)
    {
        var b1 = (long)(n - azero) * x;
        return b1 <= y;
    }
}
0