Help me in solving AMR14BP problem

My issue

Can’t solve this problem

My code

# cook your dish here

Learning course: Analysis and Design of Algorithms
Problem Link: Road Decoration in Analysis and Design of Algorithms