結果

問題 No.1071 ベホマラー
ユーザー stngstng
提出日時 2022-09-01 19:33:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 256 ms / 2,000 ms
コード長 581 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 85,356 KB
最終ジャッジ日時 2024-04-26 20:00:34
合計ジャッジ時間 4,392 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,096 KB
testcase_01 AC 38 ms
52,096 KB
testcase_02 AC 37 ms
51,968 KB
testcase_03 AC 38 ms
51,968 KB
testcase_04 AC 37 ms
51,712 KB
testcase_05 AC 37 ms
52,096 KB
testcase_06 AC 38 ms
52,096 KB
testcase_07 AC 41 ms
57,472 KB
testcase_08 AC 41 ms
57,984 KB
testcase_09 AC 37 ms
52,096 KB
testcase_10 AC 159 ms
83,328 KB
testcase_11 AC 171 ms
83,072 KB
testcase_12 AC 85 ms
80,256 KB
testcase_13 AC 177 ms
81,920 KB
testcase_14 AC 105 ms
83,448 KB
testcase_15 AC 123 ms
85,120 KB
testcase_16 AC 134 ms
85,248 KB
testcase_17 AC 175 ms
85,248 KB
testcase_18 AC 138 ms
84,992 KB
testcase_19 AC 217 ms
84,900 KB
testcase_20 AC 98 ms
78,592 KB
testcase_21 AC 256 ms
85,148 KB
testcase_22 AC 97 ms
78,592 KB
testcase_23 AC 102 ms
83,444 KB
testcase_24 AC 127 ms
85,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k,x,y = map(int,input().split())
a = [int(i)-1 for i in input().split()]

low = 0
high = (k-1+max(a))//k

def f(num):
    val = num*y
    for i in range(n):
        tmp = (max(0,a[i]-num*k)+k-1)//k
        val += tmp*x
    return val
#print(low,high)
#exit()
cnt = 0
while low+1 < high:
    c1 = int((low*2+high)/3)
    c2 = int((low+high*2)/3)
    
    if f(c1) > f(c2):
        if low == c1:
            low += 1
        else:
            low = c1
    else:
        if high == c2:
            high -= 1
        else:
            high = c2

ans = min(f(high),f(low))
print(ans)
0