-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathABC338_C.py
More file actions
92 lines (92 loc) · 2.31 KB
/
ABC338_C.py
File metadata and controls
92 lines (92 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//ABC338_C Leftover Recipes
##################################################
##################################################
import sys
input = sys.stdin.readline
n=int(input())
Q=list(map(int,input().split()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ANS=0
for i in range(10**6+1):
REST=[(Q[j]-A[j]*i) for j in range(n)]
if min(REST)<0:
break
#print(REST)
MIN=10**6
for j in range(n):
if B[j]!=0:
MIN=min(MIN,REST[j]//B[j])
ANS=max(ANS,i+MIN)
print(ANS)
##################################################
import copy
n = int(input())
Q = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = 10**10
for i in range(n):
if A[i] == 0: continue
a = min(a, Q[i]//A[i])
ans = a
for i in range(a+1):
b = 10**10
nowQ = copy.deepcopy(Q)
for j in range(n):
nowQ[j] -= (a-i)*A[j]
for j in range(n):
if B[j] == 0: continue
b = min(b, nowQ[j]//B[j])
ans = max(ans, a-i+b)
print(ans)
##################################################
n = int(input())
q = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(10**6 + 1):
aa = 10**6
f = True
for k in range(n):
if (q[k] - a[k] * i) < 0:
aa = 0
f = False
break
rem = (q[k] - a[k] * i) // b[k] if b[k] != 0 else 10 **6
aa = min(aa, rem)
if f:
ans = max(ans, i+aa)
print(ans)
##################################################
N=int(input())
Q=list(map(int,input().split()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans = 0
for x in range(10**6 + 1):
Q1 = [qi - x * ai for qi, ai in zip(Q, A)]
if min(Q1) < 0:
break
y = min([qi // bi for qi, bi in zip(Q1, B) if bi > 0])
ans = max(x + y, ans)
print(ans)
##################################################
N=int(input())
Q=list(map(int,input().split()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
mx=10**9
for k in range(N):
if A[k]!=0:
mx=min(mx,Q[k]//A[k])
p=0
for a in range(mx+1):
b=10**9
for k in range(N):
if Q[k]-A[k]*a>=0 and B[k]!=0:
b=min(b,(Q[k]-A[k]*a)//B[k])
p=max(p,a+b)
print(p)
##################################################