求助乌鸦坐飞机

19 views
Skip to first unread message

王希元

unread,
Jan 1, 2019, 5:14:30 AM1/1/19
to cs10...@googlegroups.com
思路是将每窝乌鸦分为4,2,1的组合
n,k=map(int,input().split())
a=[int(i)for i in input().split()]
four=n
two=2*n
b=list(map(lambda x:x%4,a))
c=sum(map(lambda x:x//4,a))
d=sum(map(lambda x:x//2,b))
f=sum((map(lambda x:x%2,a)))
if c>=four:
    c-=four
    if 2*c+d+f>two:
        print('NO')
    else:
        print('YES')
elif c<four:
    four-=c
    if two>d:
        two-=d
        if two+four*2>=f:
            print('YES')
        else:
            print('NO')
    elif two<=d:
        d-=two
        if four >=d and 2*four-d>=f:
            print('YES')
        else:
            print('NO')
Reply all
Reply to author
Forward
0 new messages