Ryuuji_Nakamura's blog

By Ryuuji_Nakamura, history, 19 months ago, In English

https://codeforces.me/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.

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
19 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

the idea that came to me while reading this problem is to do brute force,but if it will be stupid it will be TL. So, we can brute force every segment length of d, and we just need to find number of works at that time. We can count number of works in ans, but while we are brute forcing some works may be finished at that day,se we need to count number of finished works too in ans2. then lets create mx and mn to keep maximum work and minimum work on segment,if ans-ans2 is greater than mx,we update mx and store position,if ans-ans2 is smaller than mn,we update mn and store position. At the end just print it.My submission that passed is here:313211717