日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

HDU Employment Planning

發布時間:2023/12/8 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HDU Employment Planning 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Employment Planning

Time Limit : 2000/1000ms (Java/Other)???Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 9???Accepted Submission(s) : 7

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

A project manager wants to determine the number of the workers needed in every month. He does know the minimal number of the workers needed in each month. When he hires or fires a worker, there will be some extra cost. Once a worker is hired, he will get the salary even if he is not working. The manager knows the costs of hiring a worker, firing a worker, and the salary of a worker. Then the manager will confront such a problem: how many workers he will hire or fire each month in order to keep the lowest total cost of the project.

Input

The input may contain several data sets. Each data set contains three lines. First line contains the months of the project planed to use which is no more than 12. The second line contains the cost of hiring a worker, the amount of the salary, the cost of firing a worker. The third line contains several numbers, which represent the minimal number of the workers needed each month. The input is terminated by line containing a single '0'.

Output

The output contains one line. The minimal total cost of the project.

Sample Input

3 4 5 6 10 9 11 0

Sample Output

199 #include<iostream> using namespace std; int dp[13][100005]; int a[13]; int main() {int n;int i,j,k,min,max;int hire,salary,fire;while(cin>>n,n){max=0;scanf("%d%d%d",&hire,&salary,&fire);for(i=1;i<=n;i++){scanf("%d",&a[i]);if(a[i]>max){max=a[i];}}for(i=1;i<=max;i++){dp[1][i]=i*(hire+salary);}for(i=2;i<=n;i++){for(j=a[i];j<=max;j++){min=10000000;for(k=a[i-1];k<=max;k++){if(k<=j){dp[i][j]=dp[i-1][k]+(j-k)*hire+j*salary;}else{dp[i][j]=dp[i-1][k]+(k-j)*fire+j*salary;}if(dp[i][j]<min){min=dp[i][j];}}dp[i][j]=min;}}min=10000000;for(i=a[n];i<=max;i++){if(dp[n][i]<min){min=dp[n][i];}}cout<<min<<endl;}return 0; }

總結

以上是生活随笔為你收集整理的HDU Employment Planning的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。