Problem:


Score : 100 points

Problem Statement

Serval is fighting with a monster.

The health of the monster is H.

In one attack, Serval can decrease the monster's health by A.
There is no other way to decrease the monster's health.

Serval wins when the monster's health becomes 0 or below.

Find the number of attacks Serval needs to make before winning.

Constraints

1 \leq H \leq 10^4

1 \leq A \leq 10^4

All values in input are integers.

Input

Input is given from Standard Input in the following format:

H A

Output

Print the number of attacks Serval needs to make before winning.

Sample Input 1

10 4

Sample Output 1

3

After one attack, the monster's health will be 6.

After two attacks, the monster's health will be 2.

After three attacks, the monster's health will be -2.

Thus, Serval needs to make three attacks to win.

Sample Input 2

1 10000

Sample Output 2

1

Sample Input 3

10000 1

Sample Output 3

10000



Sample input:
10 4


Sample output:
3

Submission status: Runtime Error

Solution code:
H, N = (int(i) for i in input().split())
A = []
B = []
for i in range(N):
    a, b = (int(j) for j in input().split())
    A.append(a)
    B.append(b)
A_max = max(A)

DP = [0]
for i in range(1, H+A_max):
    dp = H*A_max
    for a, b in zip(A,B):
        if i-a>=0:
            dp = min(dp, DP[i-a] + b)
    DP.append(dp)
print(min(DP[H:]))

Submission status: Runtime Error

Solution code:
h, n = map(int, input().split())
a = input().split()
b = 0
def has_duplicates(seq):
    return len(seq) != len(set(seq))

for i in range(n):
    b += int(a[i])
if (h > b):
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
h, n = map(int, input().split())
a = input().split()
b = 0
def has_duplicates(seq):
    return len(seq) != len(set(seq))

for i in range(n):
    b += int(a[i])
if (h > b or has_duplicates(a) or len(a) > n ):
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
H = input().split()
H = [int(i) for i in H]

if H[0] > H[1]:
    H[0] = H[0] - H[1]
    count+ = 0
else:
    count+ = 1
print(count)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
c = 0
while a > 0:
  a -= b
  c += 1
print(c

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# スペース区切りの整数の入力
b, c = map(int, input().split())
# 文字列の入力
s = input()
# 出力
print("{} {}".format(a+b+c, s))
import fractions
fractions.gcd(a,b)

Submission status: Runtime Error

Solution code:
h, a = map(int, input())
print(h//a+1 if h%a != 0 else h//a)

Submission status: Runtime Error

Solution code:
H,A = int(input()),int(input())
if(H%A != 0): print((H//A) + 1)
else: print(H/A)

Submission status: Runtime Error

Solution code:
H,A = int(input()),int(input())
if(H%A != 0): print((H//A) + 1)
else: print(H/A)

Submission status: Runtime Error

Solution code:
H,A=map(int,inoput().split())
print-(-H/A)

Submission status: Runtime Error

Solution code:
import math

h = int(input())
a = int(input())
  
s=math.ceil(h/a)
print(s)

Submission status: Runtime Error

Solution code:
# http://drken1215.hatenablog.com/entry/2020/01/26/225000

H, N = map(int, input().split())
dp = [float("inf") for i in range(H+1)]

dp[0] = 0

for i in range(N):
  a, b = map(int, input().split())
  
  for j in range(H):
    dp[min(j+a, H)] = min(dp[min(j+a, H)], dp[j] + b)


print(dp[H])

Submission status: Runtime Error

Solution code:
# coding=utf-8
# Date: 2020-01-08
# Author: lee215
get = lambda: int(input().strip())
getl = lambda: input().strip()
gets = lambda: list(map(int, input().strip().split()))
getss = lambda n: [gets() for _ in range(n)]

H, N = gets()
AB = getss(N)
AB.sort(key=lambda a_b: -a_b[0] * 1.0 / a_b[1])

a0, b0 = AB[0]
dp = [0] + [float('inf')] * (H + a0)

cur = 0
while cur <= H + a0:
    dp[cur] = cur // a0 * b0
    cur += a0


for a, b in AB[1:]:
    for i in range(a, H + a0 + 1):
        dp[i] = min(dp[i], dp[i - a] + b)
print(min(dp[H:]))

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
H = map(int, input().split())

H.sorted(reverse=True)

if K >= N:
    print(0)
else:
    for i in range(K):
        del H[i]
    print(sum(H))

Submission status: Runtime Error

Solution code:
h = int(input())
a = int(input())
print(h // a + 1)

Submission status: Runtime Error

Solution code:
h = input()
a = input()
print(h // a + 1)

Submission status: Runtime Error

Solution code:
H, N = map(int, input().split())
A_list = list(map(int, input().split()))
if H <= sum(A_list):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import numpy as np

N, K = map(int, input().split())
H = list(map(int, input().split()))
if N <= K:
  print(0)
else:
  H.sort()
  ans = 0
  for i in range(N-K):
    ans += H[i]
  print(ans)

Submission status: Runtime Error

Solution code:
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    H, A = read_int_list()
    res = 0
    for i in range(n):
      H = H - A
      res += 1
      if H <= 0:
        break
    print(res)


main()

Submission status: Runtime Error

Solution code:
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    H, A = read_int_list()
    res = 0
    for i in range(n):
      H = H - A
      res += 1
    if H <= 0:
      break
    print(res)


main()

Submission status: Runtime Error

Solution code:
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    H, A = read_int_list
    res = 0
    for i in range(n):
      H = H - A
      res += 1
    if H <= 0:
      break
    print(res)


main()

Submission status: Runtime Error

Solution code:
import Math

h, a = map(int, input().split())
print(math.ceil(h/a))

Submission status: Runtime Error

Solution code:
import Math

h, a = map(int, input().split())
print(math.ceil(h//a + 1))

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
hlis = list(map(int, input().split()))
# hlis.sort(reverse=True)

for i in range(0, k):
  cache = max(hlis)
  hlis.remove(cache)
print(sum(hlis))

Submission status: Runtime Error

Solution code:
import numpy as np
from sys import stdin


## This code doesn't pass the test
# def get_result(data):
#     H, N = data[0]
#     A_and_B = np.array(data[1:])
#     calc_efficient = np.array(list(map(lambda x: float(x[0] / x[1]), A_and_B)))
#     sorted_index = np.argsort(-calc_efficient)

#     cost = 0
#     remainder_H = H
#     for i in sorted_index:
#         A, B = A_and_B[i]
#         quotient = remainder_H // A
#         if quotient > 0:
#             cost += B * quotient
#             remainder_H = remainder_H - A * quotient
#         else:
#             if remainder_H > 0:
#                 continue
#             else:
#                 break

#     return cost

## 答え (DP, ナップザック問題の典型らしい)
# 自分の解法は典型的なハマり方をしたっぽい

def get_result(data):
    # 初期化
    H, N = data[0]
    A_and_B = np.array(data[1:])
    A = A_and_B[:, 0].reshape(-1)
    B = A_and_B[:, 1].reshape(-1)

    # 最小化問題だから無限で初期化
    # DP[j] = Aの和が j の時の最小コスト (魔力)
    # 計算量は、O(NH)なのでHが少なくなるようにテーブルは作る
    inf = float("inf")
    # N × H (制約条件) のテーブルを作成
    dp =[inf for j in range(H+1)]
    # 初期値
    dp[0] = 0

    # DP (コードはなんとなく理解できた)
    for i in range(H):
        for j in range(N):
            # 魔力1つずつについてloopさせる
            if (i+1) - A[j] < 0:
                dp[i+1] = min(dp[i+1], dp[0] + B[j])
            else:
                dp[i+1] = min(dp[i+1], dp[i+1-A[j]] + B[j])

    return dp[H]

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)

Submission status: Runtime Error

Solution code:
H, A = list(map(int, input().split))
print((H + A-1)//A)

Submission status: Runtime Error

Solution code:
h, a = input().split()

print((h - 1) // 4 + 1)

Submission status: Runtime Error

Solution code:
h,a = map(int,input().split())
print(h//a+not not h%a)

Submission status: Runtime Error

Solution code:
h, a = input().split()
print(h // a)

Submission status: Runtime Error

Solution code:
    h, a = map(int, input().split())
    print((h + a - 1) // a)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
    int a,b,ans;
    cin >> a >> b;
    
    if(a%b==0)
        ans = a/b;
    else
        ans = a/b + 1;
    cout << ans << endl;
}

Submission status: Runtime Error

Solution code:
import math
a = list(map(int,input().split()))
print(math.ceil((float)a[0]/a[1]))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

#整数値龍力　複数の入力(配列で1つずつ渡される)
def input_multiple_number_as_list_sep(N):
    ins = []
    for i in range(N):
        ins.append(input())
    return ins

#2次元配列入力
def input_map():
    return [list(map(int,list(input()))) for i in range(h)]


H,N = input_multiple_number()
magics = []
maxA = 0

for i in range(N):
    A,B = input_multiple_number()
    cosper = A/B
    magics.append([A,B,cosper])
    if maxA < A: maxA = A

#magics.sort(key=lambda x:x[2],reverse=True)

inf=float("inf")
dp=[[inf for i in range(N+1)] for j in range(H+maxA+1)]
for i in range(N+1): dp[0][i]=0

for j in range(N):
    for i in range(H+maxA+1):
        dp[i][j+1] = min(dp[i-magics[j][0]][j+1]+magics[j][1],dp[i][j])

ds = dp[H:H+maxA][:]
mmm = []
for i in range(len(ds)):
    mmm.append(min(ds[i]))
print(min(mmm))

Submission status: Runtime Error

Solution code:
h = int(input())
a = int(input())
  
if h % a == 0:
  s=int(h/a)
  print(s)
  
else:
  s =int(h//a +1)
  print(s)

Submission status: Runtime Error

Solution code:
h = int(input())
a = int(input())
  
if h % a == 0:
  s=int(h/a)
  print(s)
else:
  s =int(h//a +1)
  print(s)

Submission status: Runtime Error

Solution code:
h = int(input())
a = int(input())
  
if h % a == 0:
  s=int(h/a)
  print(s)
else:
  s =int(h//a +1)
  print(h//a)
  print(s)

Submission status: Runtime Error

Solution code:

h = int(input())
a = int(input())
  
if h % a == 0:
  s=h/a
  print(s)
else:
  s =h//a +1
  print(s)

Submission status: Runtime Error

Solution code:
import math

n, d, a = map(int,input().split())
xh = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
    x,h = map(int,input().split())
    xh[i] = [x,h]

num = 0
xh.sort(key=lambda xh:xh[0])

dam = [0]*n
for i in range(n):
    res = xh[i][1]-dam[i]
    pos = xh[i][0]
    if res > 0:
        nat = math.ceil(res/a)
        num += nat
        for j in range(i+1,n):
            if xh[j][0]-d <= pos + d:
                dam[j] += a*nat
            else:
                break
    print(dam)
print(num)

Submission status: Runtime Error

Solution code:
h = int(input())  # Monster health
a = int(input())  # Servant attack
x = a
attack = 1

while h > x :
    h -= x
    attack += 1

print(attack)

Submission status: Runtime Error

Solution code:
H_str, A_str = input().split('')

print(int(H_str) // int(A_str) + 1)

Submission status: Runtime Error

Solution code:
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]

# 最強の魔法の特定
a_max = max(a for a, b in ab)
# 動的計画法用の配列の定義及び初期化
dp = [0]*(h + a_max)

for i in range(h + a_max):
	dp[i] = min(dp[i - a] + b for a, b in ab)

print(min(dp[h:]))

Submission status: Runtime Error

Solution code:
import numpy as np

H, N = map(int, input().split())
A, B = np.zeros(N, dtype=np.int), np.zeros(N, dtype=np.int)

for i in range(N):
    A[i], B[i] = map(int, input().split())

C = np.zeros(H+1, dtype=np.int)
min_cost_A = int(A[B.argmin()])
C[1:min_cost_A+1] = min(B)
sa = np.zeros(N, dtype=np.int)

def hoggg(C, A, B, i, N):
    for j in range(N):
        if A[j] >= i:
            sa[j] = B[j]
        else:
            sa[j] = C[i - A[j]] + B[j]
    return min(sa)

for i in range(min_cost_A, H+1):
    C[i] = hoggg(C, A, B, i, N)

print(int(C[H]))

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H = INT()

print(2**len("{:b}".format(H))-1)

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H = INT()

print(2**(ceil(log2(H)))-1)

Submission status: Runtime Error

Solution code:
import math,bisect
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,d,a = map(int,readline().split())
lst1 = [list(map(int,readline().split())) for i in range(n)]
lst1.sort()

#####segfunc######
def segfunc(x,y):
    return x+y

def init(init_val): #渡されたリストでsegを初期化
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x): #segの要素kをxに変更(セグ木全体の更新)
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q): #区間[p,q)での、segfuncに準じた値を返す
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
"""
最小値のセグ木 → 10**9　(最小値の更新に影響しないため)
　　和のセグ木 → 0
　　積のセグ木 → 1
　　gcdのセグ木 → 0　(gcdを更新しない値は0)
"""
ide_ele = 0

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num


#process
x = []
for i in lst1:
    x.append(i[0])


ans = 0

for i in range(n):
    k = bisect.bisect_left(x,lst1[i][0]-2*d) #手前側にあるダメージ量を確認

    r = query(k,i) #kからiまでの合計ダメージを取得

    if lst1[i][1] > r:
        if (lst1[i][1]-r)/a%1==0:
            need = (lst1[i][1]-r)//a
        else:
            need = (lst1[i][1]-r)//a+1
        ans += need
        update(i,need*a)

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

h, n = map(int,input().split())
a = np.zeros(n, dtype = int)
b = np.zeros(n, dtype = int)
for i in range(n):
    a[i], b[i] = map(int,input().split())

dp = np.zeros(10001, dtype = int)

for i in range(10001):
    dp[i] = (dp[i-a]+b).min()

print(dp[h])

Submission status: Runtime Error

Solution code:
H, A = map(int, input().split())

print(H // A + min(H % A))

Submission status: Runtime Error

Solution code:
# import math
# import numpy as np

# S = input()
# N = int(input())
H, N = map(int, input().split())
# A = list(map(int, input().split()))
# B = [int(input()) for _ in range(n)]
# A = []
# B = []
# for _ in range(N):
#     a, b = list(map(int, input().split()))
#     A.append(a)
#     B.append(b)

# 二次元配列
# [[inf, inf, inf], [inf, inf, inf]]
# dp = [[float('inf')] * (H + 1) for i in range(N + 1)]

INF = 10 ** 18
dp = [INF] * (H + 1)
dp[0] = 0

def solve():
    for i in range(N):
        a, b = list(map(int, input().split()))

        for j in range(H):
            nj = min(j + a, H)
            dp[nj] = min(dp[nj], dp[j] + b)
    return dp[H]

print(solve())

Submission status: Runtime Error

Solution code:
H,A = map(int input(),split())

if(H%A == 0):
  print(H/A)
else:
  print((H/A)+1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
H=input()
A=input()

while(1):
  	if(H==A):
    	break
  	H=H-A
    count=count+1
    
    if(H<=0):
        break
print(count)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
H=input()
A=input()
count=0

while(1):
    H=H-A
    count=count+1
    
    if(H<=0):
        break
print(count)

Submission status: Runtime Error

Solution code:
import sys

input = sys.stdin.readline
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

max_damage = max(damage for damage, cost in magic)
dp = [0] * (H + max_damage)

for x in range(1, H + max_damage):
    dp[x] = min(dp[x - damage] + cost for damage, cost in magic)

ans = min(dp[H:])

print(ans)

Submission status: Runtime Error

Solution code:
using System;
using System.IO;///
using System.Linq;///

public class A{
    public static void Main()
    {
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int h = input[0];int a = input[1];
    
        int ans = h/a;
        if (h%a>0){
            ans += 1;
        }
    Console.Write(ans);
    }
}

Submission status: Runtime Error

Solution code:
n, d, a = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
A.sort()
count = 0
for i in range(n):
    if A[i][1] > 0:
        sx = A[i][0]
        if A[i][1] % a == 0:
            count_a = A[i][1] // a
        else:
            count_a = A[i][1] // a +1
        A[i][1] -= count_a * a
        count += count_a
        for j in range(i+1, n):
            if A[j][1] > sx + d*2:
                break
            else:
                A[j][1] -= count_a * a
print(count)

Submission status: Runtime Error

Solution code:
h, a = map(int, input(),split())
count = 0

while h > 0:
  count += 1
  h = h - a
 
print(count)

Submission status: Runtime Error

Solution code:
from math import ceil
(lambda H,A : print( ceil(H/A) ))(map(int,input().split()))

Submission status: Runtime Error

Solution code:
[H, A] = input().split(" ")
return int(H/A)

Submission status: Runtime Error

Solution code:
H, A = map(int, input.split())
i = 0
while H > 0:
  H -= A
  i += 1
print(i)

Submission status: Runtime Error

Solution code:
H, A = map(int, input.split())
i = 0
while H <= 0:
  H -= A
  i += 1
print(i)

Submission status: Runtime Error

Solution code:
import fractions

h,a=map(int,input().split())

print(fractions.ceil(h,a))

Submission status: Runtime Error

Solution code:
import math
 
H,A = list(map(int, input().split()))
 
print(math.ceil(H/A)

Submission status: Runtime Error

Solution code:
A,H= map(int, input().split())
count = 0
while H <= 0:
  H -= A
  count+=1
 print(count)

Submission status: Runtime Error

Solution code:
H = int(input())
A = int(input())
if H % A == 0:
  print(H//A)
else:
  print(H//A + 1)
return

Submission status: Runtime Error

Solution code:
h,a=map(int,input(),split())

n=h/a+1

print (int(n))

Submission status: Runtime Error

Solution code:
h, n = map(int,input().split())
a = list(input().split())
for i in n:
    h -= int(a[i])

if h > 0:
    print('No')
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
from sys import stdin

h,n = [int(x) for x in stdin.readline().rstrip().split()]
a = [0]*n ;b = [0]*n

for i in range(n):
    a[i],b[i] = [int(x) for x in stdin.readline().rstrip().split()]

#最高で削られる可能性がある体力
H = max(a)

inf = 10**10

#体力をちょうどi削るために必要な最低の魔力
dp = [inf for _ in range(h+H+1)];dp[0] = 0

for i in range(n):
    for j in range(h+1):
        if dp[j+a[i]] > dp[j] + b[i]:
            dp[j+a[i]] = dp[j] + b[i]

print(min(dp[h:]))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**5)

H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
memo = [10**10]*(H+1)
memo[0] = 0
i = 0
while i <= H:
  for a, b in AB:
    memo[i] = min(memo[i], b+memo[max(0, i-a)])
  i += 1
print(memo[H])

Submission status: Runtime Error

Solution code:
H = int(input())
A = int(input())
count = 0


while H > 0:
    H -= A
    count +=1
print(count)

Submission status: Runtime Error

Solution code:
H = int(input())
A = int(input())
count = 0


while H > 0:
    H -= A
    count +=1
else:
    print(count)

Submission status: Runtime Error

Solution code:
H = input()
A = input()
count = 0


while H > 0:
    H -= A
    count +=1
else:
    print(count)

Submission status: Runtime Error

Solution code:
H = input()
A = input()
count = 0


while H > A:
    H -= A
    count +=1
else:
    print(count)

Submission status: Runtime Error

Solution code:
H,N = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
h = 2*10**4
dp = [10**9 for i in range(h+1)]
dp[0] = 0
for i in range(N):
    a = A[i]
    b = B[i]
    for j in range(h+1):
        if j < a:
            continue
        dp[j] = min(dp[j-a]+b,dp[j])
ans = 10**9
for i in range(H,h+1):
    ans = min(ans,dp[i])
print(ans)

Submission status: Runtime Error

Solution code:
i = list(map(int, input().split()))
count: int = 0
if i[0] <= i[1]:
    print("1")
else:
    while i[0] > 0:
        i[0] -= i[1]
        count += 1
    print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
N,K=input().split()
K=int(K)

A=list(map(int, input().split()))
A=np.array(A)
sort_A=np.sort(A)[::-1]
sort_A=sort_A[K:]

print(np.sum(sort_A))

Submission status: Runtime Error

Solution code:
import numpy as np
N,K=input().split()
N=int(N)
K=int(K)

A=list(map(int, input().split()))
A=np.array(A)
sort_A=np.sort(A)[::-1]
sort_A=sort_A[K:]

print(np.sum(sort_A))

Submission status: Runtime Error

Solution code:
from math import ceil
from bisect import bisect_right
n,d,a=map(int,input().split())
lis=[list(map(int,input().split())) for i in range(n)]
x=[]
lis.sort()
for i in range(n):
  x.append(lis[i][0])
ran,ans,cnt=2*d,0,0
s=[0]*(n+1)
for i in range(n):
  r=lis[i][0]+ran
  inde=bisect_right(x,r)
  if inde!=i+1:
    if ceil(lis[i][1]/a)>cnt:
      s[inde]-=ceil(lis[i][1]/a)-cnt
      s[i]+=ceil(lis[i][1]/a)-cnt
      cnt=ceil(lis[i][1]/a)
  else:
    if ceil(lis[i][1]/a)>cnt:
      s[i]+=ceil(lis[i][1]/a)-cnt
      cnt=0
for i in range(n-1):
  s[i+1]+=s[i]
print(max(s))

Submission status: Runtime Error

Solution code:
H, N = (int(i) for i in input().split())
a_b = [[int(i) for i in input().split()] for i in range(N)]
#最大の力
max_power = 0
for i in range(N):
    if a_b[i][0] > max_power:
        max_power = a_b[i][0]
p_inf = float('inf') # 正の無限大
dp = [[p_inf] * (H+max_power+10) for i in range(N+1)]
for i in range(N+1):
    dp[i][0] = 0
dp[0][0] = 0
for i in range(N):
    for j in range(H+max_power):
        if j + a_b[i][0] < H+max_power+5: #相手に与えるダメージがHよりも小さいとき
            dp[i+1][j+ a_b[i][0]] = min(dp[i+1][j]+a_b[i][1],dp[i][j+ a_b[i][0]])
        else:
            dp[i+1][H+1+max_power+5] = dp[i][H+1+max_power+5]
print(min(dp[N][H:]))

Submission status: Runtime Error

Solution code:
H, N = (int(i) for i in input().split())
a_b = [[int(i) for i in input().split()] for i in range(N)]
#最大の力
max_power = 0
for i in range(N):
    if a_b[i][0] > max_power:
        max_power = a_b[i][0]
p_inf = float('inf') # 正の無限大
dp = [[p_inf] * (H+max_power+10)
for i in range(N+1)]for i in range(N+1):
    dp[i][0] = 0
dp[0][0] = 0
for i in range(N):
    for j in range(H+max_power):
        if j + a_b[i][0] < H+max_power+5: #相手に与えるダメージがHよりも小さいとき
            dp[i+1][j+ a_b[i][0]] = min(dp[i+1][j]+a_b[i][1],dp[i][j+ a_b[i][0]])
        else:
            dp[i+1][H+1+max_power+5] = dp[i][H+1+max_power+5]
print(min(dp[N][H:]))

Submission status: Runtime Error

Solution code:
H, N = (int(i) for i in input().split())
a_b = [[int(i) for i in input().split()] for i in range(N)]
#最大の力
max_power = 0
for i in range(N):
    if a_b[i][0] > max_power:
        max_power = a_b[i][0]
p_inf = float('inf') # 正の無限大
dp = [[p_inf] * (H+max_power+10) for i in range(N+1)]for i in range(N+1):
    dp[i][0] = 0
dp[0][0] = 0
for i in range(N):
    for j in range(H+max_power):
        if j + a_b[i][0] < H+max_power+5: #相手に与えるダメージがHよりも小さいとき
            dp[i+1][j+ a_b[i][0]] = min(dp[i+1][j]+a_b[i][1],dp[i][j+ a_b[i][0]])
        else:
            dp[i+1][H+1+max_power+5] = dp[i][H+1+max_power+5]
print(min(dp[N][H:]))

Submission status: Runtime Error

Solution code:
n,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
h.sort(reverse=True)
  
if(len(h) <= k):
	print("0")
else:
	print(sum(h,k))

Submission status: Runtime Error

Solution code:
n,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
h.sort(reverse=True)
  
if(h.length <= k):
	print("0")
else:
	print(sum(h,k))

Submission status: Runtime Error

Solution code:
h=int(input())
a=int(input())
ans=1+(h-1)/a;
print("%d"%ans)

Submission status: Runtime Error

Solution code:
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

h, n = na()
a, b = [], []
for _ in range(n):
    ai, bi = na()
    a.append(ai)
    b.append(bi)
inf = 10**9
dp = [[inf]* (10**4+1) for _ in range(n+1)]
for i in range(n):
    for j in range(1, 10**4+1):
        if j < a[i]:
            dp[i+1][j] = min(dp[i][j],((j-1)//a[i]+1)*b[i])
        else:
            dp[i+1][j] = min(dp[i][j],((j-1)//a[i]+1)*b[i], dp[i+1][j - a[i]] + b[i])
print(dp[n][h])

Submission status: Runtime Error

Solution code:
# input
H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

# process
INF = 10**9
dp = [INF]*(H+max(a for a, _ in AB))
dp[0] = 0

for i in range(H):
    if dp[i] == INF:
        continue
    for a, b in AB:
        t = dp[i]+b
        if dp[i+a] > t:
            dp[i+a] = t

# output
print(min(dp[H:]))

Submission status: Runtime Error

Solution code:
H,A=map(int,raw_input().split())
ans=0
for i in range(1,10000):
  H = H-A
  ans += 1
  if H=<0:
    break
print ans

Submission status: Runtime Error

Solution code:
import math 
a,b = map(int,input().split())
print(math.ceil(a/x))

Submission status: Runtime Error

Solution code:
h = int(input())

log = {'1': 1 , '2': 3, '3': 3, '4': 7 }
i = 1
for i in range(1, h+1, 1):
    if not (str(i) in log):
        n = i // 2
        log.setdefault(str(i), log[str(n)]*2 +1)
        ##print("N(" + str(i)+ "):" + str(log[str(i)]))

print(log[str(h)])

Submission status: Runtime Error

Solution code:
import numpy as np
import math
H,N = (int(x) for x in input().split())
A = np.array([0]*N)
B = np.array([0]*N)
C = np.array([0.]*N)
for i in range(N):
    A[i],B[i] = (int(x) for x in input().split())
    C[i] = float(A[i]) / float(B[i])

indexs = np.argsort(-C)
A=A[indexs]
B=B[indexs]
C=C[indexs]

V=[[0]*(H+1) for i in range(N+1)]
for h in range(H+1):
    V[0][h] = B[0]*math.ceil(h/A[0])

for i  in range(N):
    for h in range(H+1):
        if h < A[i]:
            V[i+1][h] = V[i][h]
        elif V[i][h] > (V[i][h-A[i]]+B[i]):
            V[i+1][h] = (V[i][h-A[i]]+B[i])
        else:
            V[i+1][h] = V[i][h]

print(V[N][H])

Submission status: Runtime Error

Solution code:
my $s = <STDIN>;
my @s = split(/ /,$s);
my $ans = &ceil($s[0]/$s[1],0);
print "$ans";

sub ceil {
	my $val = shift;	# 切り上げる数
	my $col = shift;	# 小数点以下のどこまで残すか
	my $r = 10 ** $col;
	if ($val > 0) {
		my $tmp = $val * $r;
		if ($tmp == int($tmp)) {
			return $tmp / $r;
		} else {
			return int($tmp + 1) / $r;
		}
	} else {
		return int($val * $r) / $r;
	}
}

Submission status: Runtime Error

Solution code:
my $s = <STDIN>;
my @s = split(/ /,$s);
my $ans = ceil($s[0]/$s[1],0);
print "$ans";

sub ceil {
	my $val = shift;	# 切り上げる数
	my $col = shift;	# 小数点以下のどこまで残すか
	my $r = 10 ** $col;
	if ($val > 0) {
		my $tmp = $val * $r;
		if ($tmp == int($tmp)) {
			return $tmp / $r;
		} else {
			return int($tmp + 1) / $r;
		}
	} else {
		return int($val * $r) / $r;
	}
}

Submission status: Runtime Error

Solution code:
HA=input()
HA=HA.split()
n=HA[0]/HA[1]
if int(HA[0])%int(HA[1])==0:
  print(n)
else:
  print(n+1)

Submission status: Runtime Error

Solution code:
use POSIX qw(ceil);
my $s = <STDIN>;
my @s = split(/ /,$s);
my $ans = ceil($s[0]/$s[1],0);
print "$ans";

Submission status: Runtime Error

Solution code:
h=int(input())
a=int(input())
l=h
cnt=0
while(l>0):
    l=l-a
    cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
my $s = <STDIN>;
my @s = split(/ /,$s);
my $ans = ceil($s[0]/$s[1]);
print "$ans";

sub ceil {
	my $val = shift;	# 切り上げる数
	my $col = shift;	# 小数点以下のどこまで残すか
	my $r = 10 ** $col;
	if ($val > 0) {
		my $tmp = $val * $r;
		if ($tmp == int($tmp)) {
			return $tmp / $r;
		} else {
			return int($tmp + 1) / $r;
		}
	} else {
		return int($val * $r) / $r;
	}
}

Submission status: Runtime Error

Solution code:
use POSIX qw(ceil);
my $s = <STDIN>;
my @s = split(/ /,$s);
my $ans = ceil($s[0]/$s[1]);
print "$ans";

Submission status: Runtime Error

Solution code:
def win(h,a):
    l=h
    cnt=0
    while(l>0):
        l=l-a
        cnt+=1
    return cnt
  
h=int(input())
a=int(input())
print(win(h,a))

Submission status: Runtime Error

Solution code:
def calnum(H, A, n):
    rem = H - A * n
    print('HP of the monster is %d ' % H)
    return rem


H = input()
A = input()
rem = H
n = 1
while int(rem) > 0:
    rem = calnum(int(H), int(A), n)
    n = n + 1
print("倒すのに必要な回数は、%d" % int(n))

Submission status: Runtime Error

Solution code:
h,a = map(int,input().split())
n = 1
s = H - n*A
while True:
    if s <= 0:
        break
    if s >= 0:
        n += 1
    print(n)

Submission status: Runtime Error

Solution code:
hp, atk = input().split()

hp = int(hp)
atk = int(atk)

value = 0

numlist = list((input().split()))

numlist = list(map(int, numlist))

for i in range(atk):
    value = value + numlist[i]
    
if value > hp:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
H,A = int(input().split())
n = 1
s = H - n*A
while s<= 0:
	n += 1
    print(n)

Submission status: Runtime Error

Solution code:
H,A = int(input().split())
n = 1
s = H - n*A
while s <= 0:
    if s >= 0:
        n += 1
    print(n)