# 中位数 100%
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
# @param arr float浮点型一维数组 非空无序数组
# @return float浮点型
#
class Solution:
def median(self , arr ):
# write code here
n = len(arr)
arr.sort()
if n % 2 == 1:
return float(arr[n//2])
else:
a = arr[n//2-1]+arr[n//2]
return float(a/2)
# 数名字 20% 超时
names = list(input().split())
paper = input()
n = len(paper)
ans = 0
for name in names:
m = len(name)
for j in range(n):
if paper[j:j+m] == name:
ans += 1
print(ans)
# 分类置信度 10% 输出怎么处理?
import math
N, K = map(int, input().split())
logits = [[0]*K for _ in range(N)]
for i in range(N):
logits[i] = list(map(float, input().split()))
L = logits[i]
ans = [0] * K
for j in range(K):
ans[j] = math.exp(L[j])
b = sum(ans)
max_num = max(ans)
for k in range(K):
if ans[k] == max_num:
index = k
break
ans1 = round(max_num/b,6)
print(k, ans1)
# 知道了,上题应该这么写:
import math
N, K = map(int, input().split())
logits = [[0]*K for _ in range(N)]
for i in range(N):
logits[i] = list(map(float, input().split()))
L = logits[i]
ans = [0] * K
for j in range(K):
ans[j] = math.exp(L[j])
b = sum(ans)
max_num = max(ans)
for k in range(K):
if ans[k] == max_num:
index = k
break
ans1 = max_num / b
ans1 = int(ans1*10**6)
ans1 = ans1 / 10**6
print(k, '%.6f' % ans1)
# print(format(ans1, '.6f'))
# 纸张分配 90%
boy = list(map(int, input().split()))
n = len(boy)
dp = [1] * (n+2)
boys = [1] * (n+2)
boys[0] = boy[n-1]
boys[-1] = boy[0]
boys[1:n+1] = boy
ans = 0
for i in range(1,n+1):
if boys[i] > boys[i-1] and boys[i] > boys[i+1]:
dp[i] = max(dp[i-1], dp[i+1]) + 1
elif boys[i] > boys[i-1] and boys[i] <= boys[i+1]:
dp[i] = dp[i-1] + 1
elif boys[i] <= boys[i-1] and boys[i] > boys[i+1]:
dp[i] = dp[i+1] + 1
for i in range(1, n+1):
if boys[i] > boys[i-1] and dp[i] <= dp[i-1]:
ans += 1
elif boys[i] > boys[i+1] and dp[i] <= dp[i+1]:
ans += 1
print(sum(dp[1:n+1])+ans)
又要拿感谢信了,到现在一个offer都没有,考虑转行了
#网易笔试##网易##笔经#