Bzoj 1221: [HNOI2001] Software development

Source: Internet
Author: User

1221: [HNOI2001] Software development time limit:10 Sec Memory limit:162 MB
submit:1459 solved:809
[Submit] [Status] [Discuss] Description

A software company is planning an n-day software development program, according to the development plan I need NI software developers, in order to improve the efficiency of software developers, the company provides software personnel with a lot of services, one of the services is to provide each developer a daily disinfection towel, This disinfectant towel must be sterilized after one day to be used. Disinfection methods There are two, a mode of disinfection needs a day, B mode of disinfection needs B Day (B>a), a disinfection method of the cost of each towel FA, B disinfection method of the cost of each towel fb, and buy a new towel for the cost of f (new towel is disinfected, the day can be used); >FA>FB. The company's manager is planning how many new towels to buy each day, how many towels per day, and how many towels are sent per day for the B disinfection of these n days. Of course, company managers want the lowest cost. Your job is to plan how many towels to buy per day, how many towels per day, and how many towels to disinfect for B, so that the company has the lowest total cost of providing towel service in this N-day software development.

Input

1th Act N,A,B,F,FA,FB. 2nd Act N1,n2,......,nn. (Note: 1≤f,fa,fb≤60,1≤n≤1000)

Output

Minimum cost

Sample Input4 1 2 3 2 1
8 2 1 6
Sample Output38
Hintsource Analysis:

Thanks to the witty leaf children's shoes ...

This question was written at the beginning of the cost stream ... Then the leaves say you can use three points + greedy off ... Run to fly ... (However I did not use heap optimization ...)

Write three points for the first time ...

The following comes from the leaves ...

Obviously the cost and the number of towels bought into a single peak function (if not enough function value is +inf) ... And whenever you buy a towel, it's equivalent to buying it on the first day ...
So you can buy the first day of the number of towels, greedy for the value of the function, the specific greedy strategy is to buy a new towel to use, can not be used from the first day after the use of the slow wash, slow washing is not enough to use from yesterday to quickly wash ... Correctness is obviously right ...

Code:
1#include <algorithm>2#include <iostream>3#include <cstring>4#include <cstdio>5 //by Neighthorn6 #defineINF 0x3f3f3f3f7 using namespacestd;8 //facial features as ever, years as before9 Ten Const intmaxn= ++5; One  A intN,A,B,F,FA,FB,SUM,S[MAXN],RE[MAXN],NUM[MAXN]; -  -InlineintCalcintx) { the     intans=x*F; -memcpy (S,num,sizeof(s)); -memset (Re,0,sizeof(re)); -      for(intI=1; i<=n;i++){ +         if(x) { -             intLala=min (x,s[i]); +x-=lala,s[i]-=lala,re[i]+=Lala; A         } at          for(intj=1; j<=i-b-1&&s[i];j++){ -             intLala=min (re[j],s[i]); -re[j]-=lala,s[i]-=lala,ans+=fb*lala,re[i]+=Lala; -         } -          for(intj=i-a-1; j>=1&&s[i];j--){ -             intLala=min (re[j],s[i]); inre[j]-=lala,s[i]-=lala,ans+=fa*lala,re[i]+=Lala; -         } to         if(S[i]) +             returninf; -     } the     returnans; * } $ Panax NotoginsengSigned Main (void){ -scanf"%d%d%d%d%d%d", &AMP;N,&AMP;A,&AMP;B,&AMP;F,&AMP;FA,&AMP;FB); sum=0; the      for(intI=1; i<=n;i++) +scanf"%d", &num[i]), sum+=Num[i]; A     intL=1, r=sum; the      while(l<r-1){ +         intMid= (l+r) >>1, mid= (mid+r) >>1; -         if(Calc (mid) <Calc (Mid)) $R=Mid; $         Else -L=mid; -     } theprintf"%d\n", Min (Calc (l), Calc (r)); -     return 0; Wuyi}//The cap ou pas Cap. Pas Cap.
View Code

by Neighthorn

Bzoj 1221: [HNOI2001] Software development

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.