2 problems for div3 participants

Bomb Defusing II

Statement

Find how many years in range [l,r] that it has Sept.1 as a weekend(Sunday and Saturday)?

Example

l=2017,r=2019
out=2
2018/9/1 is Saturday while 2019/9/1 is Sunday

Constriants

(Div2A-Div2B)→1,000<=L<=R<=9,999
(Div2B-Div2C)→1,000<=L<=R<=1,000,000,000

Flying Mouse

Statement

You are flying on a 2D plane. Your position is (1,x) where x is given. There are N bouncy platforms. The i-th one is located at and has bouncy attribute

You can do the following moves when you are at some point (x,y):

1. parachut to (z,y-1) if

2. jump to if you are on some bouncy platform. ie.you can jump if you have

3. die if you are below some bouncy platform. ie.you will die if

What's the maximum height you can achieve when you reached x=N+1? Print -1 if you can't reach there.

Example

H={0,0,0}
B={10,0,0}
x=2
Output=7
Start at (1,2) then fly to (2,1) then fly to (1,0) then jump to (1,10) then fly to (2,9) (3,8) (4,7).You can also fly to (2,1) then fly to (3,0) then fly to (4,-1) which is not better.

Constriants

Div2B→All data doesn't exceed 1000.
(Div2B-Div2C)→All data doesn't exceed 1,000,000