How can I improve CF364 Div2B

Revision en1, by reclusion, 2016-07-23 22:20:10

Here's my code : http://pastebin.com/WPfr9ZX4

Initially all columns and rows have N items each. After item is placed on the grid I subtract 1 from all the columns and rows and update the result accordingly. On test 7 I get TLE. How can I make this faster?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English reclusion 2016-07-23 22:21:55 78
en1 English reclusion 2016-07-23 22:20:10 288 Initial revision (published)