444 D. Ratings and Reality shows

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.