-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy path分发饼干.py
More file actions
61 lines (54 loc) · 1.11 KB
/
分发饼干.py
File metadata and controls
61 lines (54 loc) · 1.11 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
#-*-coding:utf8-*-
#author : Lenovo
#date: 2018/8/23
# k = raw_input() #百度
# n = int(raw_input())
# length = len(k)
# dp = [0] * n
# if k[0] == 'X':
# for d in range(10):
# _ = d % n
# dp[_] += 1
# else:
# dp[int(k[0]) % n] = 1
#
# for i in range(1, length):
# new_dp = [0] * n
# for j in range(n):
# if dp[j]:
# if k[i] == 'X':
# for d in range(10):
# new_j = (j*10+d) % n
# new_dp[new_j] += dp[j]
# else:
# new_j = (j*10+int(k[i])) % n
# new_dp[new_j] += dp[j]
# dp = new_dp
#
# print(dp[0])
# dp = [0] * 10
# print(dp)
def findContentChildren(g, s):
"""
:type g: List[int]
:type s: List[int]
:rtype: int
"""
count=0
g=sorted(g)
s=sorted(s)
while len(g) and len(s):
if s[0]<g[0]:
s.pop(0)
else:
s.pop(0)
g.pop(0)
count+=1
return count
res=findContentChildren([10,9,8,7],
[5,6,7,8])
print(res)
ss=[1,6,4,5]
sss=[1,4,7,2]
print(sorted(ss))
print(sorted(sss))