2012 summer practice contest 5

J: A simple problem with interval