菜鸡的网易2019.8.3笔试(请教大佬来讨论)

不是大佬,以下代码都能过样例,但是
o(╥﹏╥)o

1、40分

# -*- encoding: utf-8 -*-
"""
@File    : 倒数排列.py
@Time    : 2019/8/3 15:15
@Author  : cs
@content: 
"""
while True:
    try:
        n=int(input())
        l=list(map(int,input().split()))
        res=l.copy()
        l.sort()
        output=[]
        set(output)
        def back(first=0):
            if first==n:
                # if l[:] not in output:
                output.append(l[:])
            for i in range(first,n):
                l[first],l[i]=l[i],l[first]
                back(first+1)
                l[first],l[i]=l[i],l[first]
        back()
        output.sort()
        index=output.index(res)
        ans=output[len(output)-1-index]
        for i in ans:
            print(i,end=" ")
    except:
        break

2、10分,这个我没有或,因为不是很熟python的位或运算

# -*- encoding: utf-8 -*-
"""
@File    : 按位或.py
@Time    : 2019/8/3 15:36
@Author  : cs
@content: 
"""
def Or(num1,num2):
    bina=bin(num1)|bin(num2)
n=int(input())
collect=[]
for i in range(n):
    l=list(map(int,input().split()))
    if l[0]==1:
        tmp=[]
        for c in range(len(collect)):
            tmp.append(collect[c])
        collect.append(i for i in tmp if i not in collect)
    else:
        if l[1] not in collect:
            print("NO")
        else:
            print("YES")

3、0分,题目没怎么看懂

while True:
    try:
                # -*- encoding: utf-8 -*-
        """
        @File    : 最大最小值.py
        @Time    : 2019/8/3 15:59
        @Author  : cs
        @content: 
        """
        n=int(input())
        l=list(map(int,input().split()))
        out=[]
        Max=0
        for i in range(n):
            if l[i]>Max:
                Max=l[i]
            out.append(Max)
        out.sort()
        for i in out:
            print(i,end=" ")
    except:
        break

4、0分,想法感觉没问题,但是就是0分

# -*- encoding: utf-8 -*-
"""
@File    : 序列维护.py
@Time    : 2019/8/3 16:15
@Author  : cs
@content: 
"""
while True:
    try:
        n,q=map(int,input().split())
        seq=list(map(int,input().split()))
        seq.sort(reverse=True)
        for i in range(q):
            count=0
            t=int(input())
            for j in range(len(seq)):
                if seq[j]>=t:
                    seq[j]-=1
                    count+=1
                else:
                    break
            print(count)
    except:
        break
#网易##笔试题目##笔经##题解#
全部评论
最大值的最小值可以看一下我刚写的博客https://blog.csdn.net/wh_0727/article/details/98364184 语言不同但是大家可以探讨一下思路  我的是C++
点赞 回复
分享
发布于 2019-08-03 19:46
好滴
点赞 回复
分享
发布于 2019-08-03 23:02
联易融
校招火热招聘中
官网直投

相关推荐

头像
点赞 评论 收藏
转发
点赞 6 评论
分享
牛客网
牛客企业服务