結果

問題 No.1071 ベホマラー
ユーザー なつつーくなつつーく
提出日時 2020-06-06 12:27:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 248 ms / 2,000 ms
コード長 736 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 19,796 KB
最終ジャッジ日時 2023-08-25 00:27:36
合計ジャッジ時間 4,517 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,960 KB
testcase_01 AC 17 ms
8,180 KB
testcase_02 AC 17 ms
8,044 KB
testcase_03 AC 15 ms
8,048 KB
testcase_04 AC 16 ms
8,164 KB
testcase_05 AC 16 ms
8,040 KB
testcase_06 AC 15 ms
8,116 KB
testcase_07 AC 16 ms
7,976 KB
testcase_08 AC 15 ms
8,048 KB
testcase_09 AC 16 ms
8,040 KB
testcase_10 AC 209 ms
17,472 KB
testcase_11 AC 196 ms
16,944 KB
testcase_12 AC 131 ms
14,108 KB
testcase_13 AC 178 ms
16,028 KB
testcase_14 AC 209 ms
17,604 KB
testcase_15 AC 240 ms
19,180 KB
testcase_16 AC 238 ms
19,172 KB
testcase_17 AC 247 ms
19,176 KB
testcase_18 AC 241 ms
19,796 KB
testcase_19 AC 248 ms
19,096 KB
testcase_20 AC 213 ms
19,040 KB
testcase_21 AC 91 ms
19,108 KB
testcase_22 AC 216 ms
19,092 KB
testcase_23 AC 91 ms
19,092 KB
testcase_24 AC 231 ms
19,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#-------------------------------------------------------------------
import sys
def p(*_a):
  return
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------
import math

N,K,X,Y = map(int, input().split())
A = list(map(int, input().split()))

B = sorted(A)
C = [math.ceil((b-1)/K) for b in B]

p("A=",A)
p("B=",B)
p("C=",C)

hp = 1
ans = 0
for i in range(N):
  p("i, ans, hp = ", i, ans, hp)
  if B[i] <= hp: continue

  zan = B[i] - hp
  kai = math.ceil(zan / K)
  p("zan, kai =",zan, kai)

  if (N-i)*X >= Y:
    ans += kai * Y
    hp += kai * K
  else:
    ans += kai * X
    B[i] -= kai * K

  p("i, ans, hp = ", i, ans, hp)
  p("B=",B)



print(ans)
0