A naive solution of finding max seq according to rules