A model has two kinds of activities.
① take pictures and earn money a. ② Concert, spend B
A timetable for the two types of work given to the model.
Model can choose a time to hold a symposium, then he took photos of the money C. It will cost D to start a concert.
It is not possible to lose money until the model symposium and after Len (which will take effect early in the day). Ask you to output the minimum number of seminar days. No output-1..
ll N, a, B, C, D, St, Len;struct node{ll Tim, tp;} p[n];ll Calc1 (ll x) {if (x==-1) return 0; return x? A:-B;} ll CALC2 (ll x) {return x? C:-D;} ll tail = 0;ll mi = inf;ll res = 0;ll sum = 0;int Main () {SDF (n), SDF (a), SDF (b), SDF (c), SDF (d), SDF (ST), SDF (LEN); P[0].tim =-1, p[0].tp =-1; P[n + 1].tim = 1e18;//here to open the big point, 0x3f3f3f3f not enough for (I, 1, N) SDF (P[i].tim), SDF (P[I].TP); For (i, 0, n) {sum + = Calc1 (P[I].TP); if (Sum <-st) {cout <<-1; return 0; } while (P[tail + 1].tim <= P[i].tim + len) {++tail, res + = CALC2 (P[TAIL].TP); Chkmin (MI, res); } if (sum + mi >=-st) {cout << P[i].tim + 1; return 0; } Mi-= CALC2 (p[i + 1].tp); Res-= CALC2 (p[i + 1].tp); } return 0;}
444 D. Ratings and Reality shows