美团 3.13笔试AC
1.
n,m=map(int,input().split()) path,nums=[],[] res=[[0]*n for _ in range(m)] for i in range(n): path=list(map(int,input().split())) for j in range(m): res[j][i]=path[j] for i in range(m): for j in range(n): if j<n-1: print(res[i][j],end=' ') else: print(res[i][j])2.
s=input() n=len(s) left,right=0,0 res=[] while right<n: while right<n and not s[right].isdigit(): right+=1 left=right while right<n and s[right].isdigit(): right+=1 string=s[left:right] cur=0 if string: for i in string: cur=cur*10+int(i) res.append(cur) res.sort() for i in res: print(i)
3.
n,k=map(int,input().split()) nums=list(map(int,input().split())) left,right=0,0 end=n-k+1 dic={} res=[] count=0 while right<n: num1=nums[right] dic[num1]=dic.get(num1,0)+1 right+=1 if right-left==k: counter=sorted(dic.items(),key=lambda k:(k[1],-k[0])) num2=nums[left] dic[num2]-=1 left+=1 print(counter[-1][0]) count+=1 if count==end: break4,5只会骗分。。。比秋招做的还烂