Problem:


宿題 (Homework) 

問題

冬休みの宿題に毎回苦しめられてきた JOI 君が，今回は宿題を計画的に実行することにした．宿題は国語と算数のドリルであり，国語のドリルは A ページ，算数のドリルは B ページある．

JOI 君は，1 日に国語のドリルを最大 C ページと，算数のドリルを最大 D ページ進めることができるが，宿題をするとその日は遊ぶことができない．

冬休みは L 日あり，JOI 君は冬休み中に宿題を終わらせなければならない．JOI 君が冬休み中に最大で何日遊べるかを求めるプログラムを作成せよ．

入力

入力は 5 行からなり，1 行に 1 つずつ正の整数が書かれている．

1 行目には整数 L (2 ≦ L ≦ 40) が書かれており，冬休みの日数を表す．

2 行目には整数 A (1 ≦ A ≦ 1000) が書かれており，国語のドリルのページ数を表す．

3 行目には整数 B (1 ≦ B ≦ 1000) が書かれており，算数のドリルのページ数を表す．

4 行目には整数 C (1 ≦ C ≦ 100) が書かれており，JOI 君が 1 日に進めることができる国語のドリルの最大ページ数を表す．

5 行目には整数 D (1 ≦ D ≦ 100) が書かれており，JOI 君が 1 日に進めることができる算数のドリルの最大ページ数を表す．

ただし，与えられる入力データにおいては，JOI 君が冬休み中に宿題を必ず終わらせることができ，
少なくとも 1 日は遊べることが保証されている．

 出力

JOI 君が冬休み中に遊べる日数の最大値を 1 行で出力せよ．

  入出力例

入力例 1

  

20
25
30
6
8

出力例 1

   

15

入出力例 1 では，冬休みは 20 日間あり，国語のドリルが 25 ページ，算数のドリルが 30 ページある．JOI 君は 1 日に国語のドリルを最大 6 ページ，算数のドリルを最大 8 ページ進めることができる．例えば JOI 君が冬休み初日から国語のドリルを 6 ページ，算数のドリルを 8 ページずつ進めたとすると，国語のドリルを 5 日目に，算数のドリルを 4 日目に終わらせることができ，15 日間遊ぶことができる．これが JOI 君が冬休み中に遊べる日数の最大値なので，15 を出力する．

入力例 2

  

15
32
48
4
6

出力例 2

   

7

入出力例 2 では，
例えば JOI 君が初日から国語のドリルを 4 ページ，算数のドリルを 6 ページずつ進めたとすると，8 日目に両方のドリルを終わらせることができ，7 日間遊ぶことができる．これが JOI 君が冬休み中に遊べる日数の最大値なので，7 を出力する．

問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。



Sample input:
20
25
30
6
8


Sample output:
15

Submission status: Wrong Answer

Solution code:
l=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
if a%c==0 and b%d==0:
  if a/c>=b/d:
    print(l-(a//c))
  else:
    print(l-(b//d))
else:
  x=(a//c)+1
  y=(b//d)+1
  if x>=y:
    print(l-x)
  else:
    print(l-y)

Submission status: Wrong Answer

Solution code:
import math
l = [input() for i in range(5)]
print l[0] - int(max(math.ceil(l[1]/l[3]), math.ceil(l[2]/l[4])))

Submission status: Wrong Answer

Solution code:
L,A,B,C,D = input(),input(),input(),input(),input()
if(A/C > B/D):
    print L-A/C
else:
    print L-B/D

Submission status: Accepted

Solution code:
# coding: utf-8

import math

L, A, B, C, D = [int(input()) for i in range(5)]
print(L - max(math.ceil(A/C), math.ceil(B/D)))

Submission status: Accepted

Solution code:
l=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
if a%c==0 or b%d==0:
  if a/c>=b/d:
    print(l-(a//c))
  else:
    print(l-(b//d))
else:
  x=(a//c)+1
  y=(b//d)+1
  if x>=y:
    print(l-x)
  else:
    print(l-y)

Submission status: Accepted

Solution code:
import math
l = [input() for i in range(5)]
print l[0] - int(max(math.ceil(float(l[1])/l[3]), math.ceil(float(l[2])/l[4])))

Submission status: Accepted

Solution code:
l=int(input())

a=[]

for i in range(4):
    x=int(input())
    a.append(x)
r1=0
r2=0

if a[0]%a[2]==0:
    r1=a[0]//a[2]
else:
    r1=a[0]//a[2]+1

if a[1]%a[3]==0:
    r2=a[1]//a[3]
else:
    r2=a[1]//a[3]+1

print(l-max(r1,r2))

Submission status: Accepted

Solution code:
L,A,B,C,D = [int(input()) for _ in range(5)]
print(L - max((A - 1) // C,(B - 1) // D) - 1)

Submission status: Accepted

Solution code:
l,a,b,c,d=[input() for _ in xrange(5)]
print l-max(-(-a/c),-(-b/d))

Submission status: Accepted

Solution code:
L,A,B,C,D = [input() for _ in range(5)]
print L-max((A+C-1)/C, (B+D-1)/D)

Submission status: Accepted

Solution code:
import math
re_day = int(input())
ko_hom = int(input())
ma_hom = int(input())
ko_sp = int(input())
ma_sp = int(input())
print(re_day - math.ceil(max(ko_hom/ko_sp,ma_hom/ma_sp)))

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
while b>0 or c>0:
        a-=1
        b-=d
        c-=e
print(a)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0576

"""
import sys
from sys import stdin
from math import ceil
input = stdin.readline


def main(args):
    L = int(input())
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())

    days_to_finish_A = ceil(A / C)
    days_to_finish_B = ceil(B / D)
    print(L - max(days_to_finish_A, days_to_finish_B))


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
L,jp,mp,j,m=[int(input())for i in range(5)]
print(int(L-max([jp/j,mp/m]))//1)

Submission status: Accepted

Solution code:
import math
def main():
    L = int(input())
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())

    hoge = math.ceil(A / C)
    fuga = math.ceil(B / D)

    if hoge >= fuga:
        print(L - hoge)
    else:
        print(L - fuga)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from math import ceil
f = lambda:int(input())
L = f();A = f();B = f();C = f();D = f()
days = max(ceil(A / C) ,ceil(B / D))
print(L-days)

Submission status: Accepted

Solution code:
l = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(l - max(a // c + 1 if a % c else a // c, b // d + 1 if b % d else b // d))

Submission status: Accepted

Solution code:
# AOJ 0576: Homework
# Python3 2018.6.30 bal4u

L, A, B, C, D = [int(input()) for i in range(5)]
a, b = (A-1)//C+1, (B-1)//D+1
if b > a: a = b
print(L-a)

Submission status: Accepted

Solution code:
import math

L = input()
A = input()
B = input()
C = input()
D = input()

print int(L-max(math.ceil(float(A)/C),math.ceil(float(B)/D)))

Submission status: Accepted

Solution code:
l = int(raw_input())
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
d = int(raw_input())

print l - max((a + c - 1) / c, (b + d - 1) / d)

Submission status: Accepted

Solution code:
L=input()
A=input()
B=input()
C=input()
D=input()
while (A >0 or B >0):
    L -= 1
    A -= C
    B -= D
print L

Submission status: Accepted

Solution code:
L = int(raw_input())
A = int(raw_input())
B = int(raw_input())
C = int(raw_input())
D = int(raw_input())
print L - max((A + C - 1) / C, (B + D - 1) / D)

Submission status: Accepted

Solution code:
import math
L,A,B,C,D=[input() for i in range(5)]
t1=math.ceil(A/float(C))
t2=math.ceil(B/float(D))
print L-int(max(t1,t2))

Submission status: Accepted

Solution code:
l,a,b,c,d=[input() for i in range(5)]
print l-max((a+c-1)/c,(b+d-1)/d)

Submission status: Accepted

Solution code:
import math 

L = input()
A = input()
B = input()
C = input()
D = input()

print int(L - max(math.ceil(float(A) / C), math.ceil(float(B) / D)))

Submission status: Accepted

Solution code:
L,A,B,C,D = input(),input(),input(),input(),input()

if(A%C != 0):
    N = A/C + 1
else:
    N = A/C

if(B%D != 0):
    M = B/D + 1
else:
    M = B/D
if(M > N):
    print L - M
else:
    print L - N

Submission status: Accepted

Solution code:
l,a,b,c,d=[input() for i in [1]*5]
print l-max((a+c-1)/c,(b+d-1)/d)

Submission status: Accepted

Solution code:
l=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())

aa=a//c
if a%c!=0:
    aa+=1
bb=b//d
if b%d!=0:
    bb+=1
if aa>bb:
    print(l-aa)
else:
    print(l-bb)

Submission status: Accepted

Solution code:
import math

l = [int(input()) for i in range(5)]
d = max( math.ceil(l[1]/l[3]), math.ceil(l[2]/l[4]))
print(l[0]-d)

Submission status: Accepted

Solution code:
L, A, B, C, D = [int(input()) for _ in range(5)]
print(L - max(-(-A // C), -(-B // D)))

Submission status: Accepted

Solution code:
L = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())

if A % C == 0 :
    Kokugo = A // C
else :
    Kokugo = A // C + 1
if B % D == 0 : 
    Math = B // D
else :
    Math = B // D + 1
print(L - max(Kokugo, Math))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
L=int(input())
A=int(input())
B=int(input())
C=int(input())
D=int(input())


if A%C==0 and B%D==0:
    X=A//C
    Y=B//D
    X,Y=sorted([X,Y])
    print(L-Y)
elif A%C==0 and B%D!=0:
    X=A//C
    Y=(B//D)+1
    X,Y=sorted([X,Y])
    print(L-Y)
elif A%C!=0 and B%D==0:
    X=(A//C)+1
    Y=B//D
else:
    X=(A//C)+1
    Y=(B//D)+1
    X,Y=sorted([X,Y])
    print(int(L-Y))

Submission status: Accepted

Solution code:
int_list = []
for num in range(5):
    num1 = int(input())
    int_list.append(num1)
num2 = int_list[1] // int_list[3] + 1
num3 = int_list[2] // int_list[4] + 1
if num2 > num3:
    if int_list[1] % int_list[3] == 0:
        num2 -= 1
        i = int_list[0] - num2
    else:
        i = int_list[0] - num2
else:
    if int_list[2] % int_list[4] == 0:
        num3 -= 1
        i = int_list[0] - num3
    else:
        i = int_list[0] - num3
print(i)

Submission status: Accepted

Solution code:
import sys
import math
l=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
j_day=a//c
j_amr=a%c
if(j_amr != 0):
    j_day=j_day+1
m_day=b//d
m_amr=b%d
if(m_amr != 0):
    m_day=m_day+1
if(j_day>=m_day):
    study_day=j_day
else:
    study_day=m_day
day=l-study_day
print(day)

Submission status: Accepted

Solution code:
L=int(input())
A=int(input())
B=int(input())
C=int(input())
D=int(input())
print(L-max((A+C-1)//C,(B+D-1)//D))

Submission status: Accepted

Solution code:
import math
a = [int(input()) for i in range(5)]
b = sorted([math.ceil(a[1]/a[3]),math.ceil(a[2]/a[4])])
print(a[0]-b[-1])

Submission status: Accepted

Solution code:
l = int(input()) # 冬休みの日数
a = int(input()) # 国語ページ数
b = int(input()) # 算数ページ数
c = int(input()) # 国語消化
d = int(input()) # 算数消化

import math

print(l - max(math.ceil(a/c), math.ceil(b/d)))

Submission status: Accepted

Solution code:
#A
import math
L = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())

print(L-max(math.ceil(A/C),math.ceil(B/D)))

Submission status: Accepted

Solution code:
L = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())

print(L - max((A+C-1) // C, (B+D-1) // D))

Submission status: Accepted

Solution code:
import math

L = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(L - max(math.ceil(a/c), math.ceil(b/d)))

Submission status: Accepted

Solution code:
L=int(input())
A=int(input())
B=int(input())
C=int(input())
D=int(input())
if A//C>=B//D:
    if A%C==0:
        print(L-A//C)
    else:
        print(L-A//C-1)
else:
    if B%D==0:
        print(L-B//D)
    else:
        print(L-B//D-1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
L = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())

if A % C == 0:
    X = A // C
if A % C != 0:
    X = A // C + 1
if B % D == 0:
    Y = B // D
if B % D != 0:
    Y = B // D + 1
ans = L - max(X,Y)
print(ans)

Submission status: Accepted

Solution code:
import math
l=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(l-max(math.ceil(a/c),math.ceil(b/d)))

Submission status: Accepted

Solution code:
L = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())

day_k = 0
day_s = 0
if A % C == 0:
    day_k = A // C
else:
    day_k = A // C + 1
if B % D == 0:
    day_s = B // D
else:
    day_s = B // D + 1

print(L - max(day_k, day_s))

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

if b%d == 0:
  x = b // d
else:
  x = b // d +1

if c%e == 0:
  y = c // e
else:
  y = c // e +1

if x >= y:
  print(a-x)
else:
  print(a-y)

Submission status: Accepted

Solution code:
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(int(n-max(a/c,b/d)))

Submission status: Accepted

Solution code:
l = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if a % c == 0:
    kokugo = a // c
else:
    kokugo = a // c + 1

if b % d == 0:
    sansu = b // d
else:
    sansu = b // d + 1

print(l - max(kokugo, sansu))

Submission status: Accepted

Solution code:
all = input()
japaneseAll = input()
mathAll = input()
japaneseCan = input()
mathCan = input()
if japaneseAll % japaneseCan == 0:
    japanseNeed = japaneseAll / japaneseCan
else:
    japanseNeed = japaneseAll / japaneseCan + 1
if mathAll % mathCan == 0:
    mathNeed = mathAll / mathCan
else:
    mathNeed = mathAll / mathCan + 1
if mathNeed < japanseNeed:
    print all - japanseNeed
else:
    print all - mathNeed

Submission status: Runtime Error

Solution code:
while True:
  l=int(input())
  a=int(input())
  b=int(input())
  c=int(input())
  d=int(input())
  if a%c==0 and b%d==0:
    if a/c>=b/d:
      print(l-(a//c))
    else:
      print(l-(b//d))
  else:
    x=(a//c)+1
    y=(b//d)+1
    if x>=y:
      print(l-x)
    else:
      print(l-y)