Consider the grid as Chessboard and partition the positions into White and Black colors.
Add edges from Whites to Blacks if that white and black are adjacent.
Create a dummy white and dummy black node. Consider that the dummies are adjacent to all positions.
Run Min Cost Max Flow with the layout Source -> Whites -> Blacks -> Sink where Source -> White and Black -> Sink edges has capacity 1 and cost the negated value of the strength of the titan at that position. For dummies however, capacity = n, cost = 0.