https://mirror.codeforces.com/contest/2014/problem/D
My logic was to first find all the valid indices with an interval of d, then input all the job indices, sort them, and proceed. Let's denote the range of visits for the brother and mother as l and r, and the job durations as f and s. If r is less than f, then the job is out of range and will not be counted. The same applies to jobs where l is greater than s. To handle this, I used upper_bound and lower_bound, but it's giving the wrong answer, and I'm not sure why.









