Codeforces round#481(Div.3)-978G Tutorial
Разница между en6 и en7, 5 символ(ов) изменены
[978G-Petya's Exam](http://mirror.codeforces.com/contest/978/problem/G)↵
----------------------------------------------------------------↵
1. This is a greedy problem. First thing to notice is that exam which is occurring earlier compared to others should be prepared first, i.e. exam which is having less $d_i$ should be prepared earlier(if value of $s$ allows to do so). ↵

2. Sort the exams in the increasing order of $d_i$. If we go through solution we can see that it gives optimum solution. ↵

3. Let us take an exam from the sorted order = {$s_i$ , $d_i$, $c_i$}. Since we have sorted exams $\implies$, $1\leq$$j$$\leq$$n$ AND $j$$\neq$$i$; either $d_i$$\leq$$d_j$ or $j^{th}$ exam is completed(We are processing in increasing order of $d_i$). Now we have to prepare $c_i$ days for exam $i$ in the interval $s_i$ and $d_i$(and obviously we are forced to do so, so that's an optimal step). Now since all other exams(for which preparation is not done yet) are after $i^{th}$ exam, **what is the best way to choose $c_i$ days in the interval $[s_{i},d_{i}]$ such that we leave better opportunities for the preparation of other exams**?If we iterate from $s_i$ to $d_i$ and choose first $c_i$ days which are free for preparation. Hence our solution is optimal. ↵

4. Worst case time complexity is : O(m*n).↵

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en7 Английский aMitkvikram 2018-05-13 22:21:37 5
en6 Английский aMitkvikram 2018-05-13 22:18:21 0 (published)
en5 Английский aMitkvikram 2018-05-13 22:18:04 6
en4 Английский aMitkvikram 2018-05-13 22:16:24 6
en3 Английский aMitkvikram 2018-05-13 22:15:02 49
en2 Английский aMitkvikram 2018-05-13 22:14:13 4
en1 Английский aMitkvikram 2018-05-13 22:13:29 1286 Initial revision (saved to drafts)