Advertisement
Taigar2000

B

Nov 14th, 2020
775
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. N, K = map(int, input().split())
  2. d = [0]*(N+1)
  3. arr = []
  4. n = N+1
  5. for i in range(K):
  6.     arr.append(list(map(int, input().split())))
  7.     d[arr[-1][0]] = 1
  8. r = 0
  9. for i in range(len(d)):
  10.     if(d[i]):
  11.         if(i%7!=6 and i%7!=0):
  12.             r += 1
  13.         for j in arr:
  14.             if(i == j[0]):
  15.                 j[0] += j[1]
  16.                 if(j[0] <= N):
  17.                     d[j[0]] = 1
  18. print(r)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement