Trigger on using stack at problem 313D — Ilya and Roads

Revision en1, by Luftwaffe, 2018-12-15 12:45:31

https://codeforces.com/problemset/problem/313/D Hello everyone. I've solved this problem by dynamic programming, yeah but my teacher after looking at the problem, he said it can be solved by using stack, I'm really "WTF" after what he said, I did ask him how to solve it like that but he explained it and I couldn't understand, so can anyone say whether it is possible to solve it by using stack, I'm kinda curious about that approach ? Thanks a lot.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Luftwaffe 2018-12-15 12:45:31 506 Initial revision (published)