summaryrefslogtreecommitdiffstats
path: root/Main/Python/2013/S2.py
blob: adab6be8a0b835d3b4dfb294be5ea3a7bc013502 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
W = int(input())
N = int(input())
broken = False
passed = 0
bridge = [0,0,0,0]
def shift(t, val):
    for i in range(3):
        t[i] = t[i+1]
    t[-1] = val
for i in range(N):
    w = int(input())
    if not broken:
        shift(bridge,w)
        if sum(bridge) > W:
            broken = True
            continue
        passed += 1




print(passed)