It is easy to think of two points, the problem is with the feasibility of judging a solution. Greedy, up to 20,000 points in time, you can simulate each point in time, sort events by start time,
Each time you prioritize a task that has already started and the earliest end time, if a task does not end before deadline, it is not feasible to indicate the current solution.
The upper bounds of R are not well estimated, (far from the sum, but larger than MAXW, because the task overlaps in time), slightly larger.
#include <bits/stdc++.h>using namespacestd;Const intMAXN = 1e4+5;structjob{intr,d,w; BOOL operator< (ConstJob &rh)Const { returnD > Rh.d;//return r < RH.R | | (r = = RH.R && d < Rh.d); } voidIn () {scanf ("%d%d%d",&r,&d,&W); }}J[MAXN];BOOLcmpConstJob&a,ConstJOB&B) {returnA.R <B.R;}Const intMaxd =2e4;intN;BOOLOkintm) {Priority_queue<Job>Q; for(inti =2, j =0; I <= Maxd; i++){ while(J < n && J[J].R < i) Q.push (j[j++]); intW =m; while(w>0&&q.size ()) {Job cur=q.top (); Q.pop (); if(CUR.W <=W) {W-=CUR.W; }Else { if(CUR.D <= i)return false; CUR.W-=W; Q.push (cur); W=0; } } if(j = = n && q.empty ())return true; } return false;}intMain () {//freopen ("In.txt", "R", stdin); intT scanf"%d",&T); while(t--) {scanf ("%d",&N); for(inti =0; I < n; i++) J[i]. In (); Sort (J,j+n,cmp); intL =1, R =1e4,m; for(; L<r; Ok (M)? r=m:l=m+1) M = (l+r) >>1; printf ("%d\n", L); } return 0;}
Uvalive 4254 Processor