惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
L
LangChain Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
M
MIT News - Artificial intelligence
N
Netflix TechBlog - Medium
Vercel News
Vercel News
D
DataBreaches.Net
Microsoft Azure Blog
Microsoft Azure Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
Blog — PlanetScale
Blog — PlanetScale
Cloudbric
Cloudbric
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Security Blog
Microsoft Security Blog
月光博客
月光博客
I
InfoQ
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Hugging Face - Blog
Hugging Face - Blog
Security Latest
Security Latest
T
Threatpost
GbyAI
GbyAI
K
Kaspersky official blog
S
SegmentFault 最新的问题
Schneier on Security
Schneier on Security
V
V2EX
W
WeLiveSecurity
Recorded Future
Recorded Future
WordPress大学
WordPress大学
L
LINUX DO - 最新话题
O
OpenAI News
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
The Last Watchdog
The Last Watchdog
有赞技术团队
有赞技术团队
Attack and Defense Labs
Attack and Defense Labs
N
News | PayPal Newsroom
H
Help Net Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Webroot Blog
Webroot Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Troy Hunt's Blog
腾讯CDC
Scott Helme
Scott Helme
P
Privacy & Cybersecurity Law Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
E
Exploit-DB.com RSS Feed

博客园 - zy_nic

SRM 424 div1 900 ProductOfPrices 翻译 .. emacs的c++mode contest contest 我的2-sat模板 Solution to GCJ Practice Contest Problem C, Cycles 约瑟夫问题的数学方法 我的模板 图的应用 pku3411 今天的比赛 关于建图的 死老鼠安装成功 pku3141 先帖个题目上来 hnu 11028 joj 儿死三八 pku 1273
hnu 11015
zy_nic · 2007-09-17 · via 博客园 - zy_nic
Projects
Time Limit: 5000ms, Special Time Limit:12500ms, Memory Limit:65536KB
Total submit users: 20, Accepted users: 18
Problem 11015 : No special judgement
Problem description
In a certain week, a company wants to finish m projects. To this end, the company can employ at most n people from the unemployment agency for a period of one week. Each external employee will cost the company salary euro, unless the project in which he/she is involved is not completed in time. In that case no payment is due.
For each project the company knows from experience the probability that the project will be completed within a week, as a function of the number of employees working on it. These probabilities are given as percentages pij, where i (with 1 <= i <= m) is the number of the project and j is the number of people working on it. Of course, when nobody is working on a project i, the probability pi0 is zero percent.
If project i is indeed finished within a week, the company earns reward(s) euro; if it is not ready in time, the company has to pay a fine of punishment(i) euro.
Of course the company wants to maximize its total expected profit① at the end of the week by finding the optimal number of external employees to hire, and how to divide them over the projects. The optimal number of employees is the total number of people needed to achieve the maximal expected profit. Your task in this matter is to calculate this optimal number of external employees. Remember that at most n people are available. Furthermore: if a person is employed, he / she works on one and only one project.
Input
The first line of the input file contains a single number: the number of test cases to follow. Each test case has the following format:
One line with one integer m with 1 <= m <= 100: the number of projects.
            One line with one integer n with 0 <= n <= 100: the maximal number of available employees.
            One line with one integer salary with 0 <= salary <= 1,000: the salary of one employee. Remember that the salary is given in euros.
m lines, each line corresponding to a project i, containing n integers pi1, pi2, ……, pin (the percentages, with 0 <= pi1, pi2, ……, pin <= 100), followed by two integers corresponding to the reward and the punishment for project i. All values are separated by single spaces. Both reward and punishment are given in euros and are between 0 and 100,000(boundaries included).
Output
For every test case in the input file, the output should contain two lines.
The first line contains the maximal expected profit in eurocents.
The second line contains the total number of external employees that must be hired in order to achieve this maximal expected profit. If the maximal expected profit can be achieved by different (total) numbers of employees, then these different numbers must be given in increasing order. Numbers have to be separated by single spaces.
①Let p (0 <= p <= 1) be the probability that a job is finished in time, and let E1 be the profit in that case. Furthermore, let E2 be the (negative) profit in case the job is not finished in time. Then the expected profit for this particular job is p * E1 + (1 - p) * E2.
Sample Input
3
            1
            4
            200
            90 100 100 100 2000 0
            2
            2
            100
            80 80 2100 500
            0 100 1700 500
            3
            4
            100
            100 80 80 70 1000 100
            100 90 80 90 500 50
            100 70 60 50 700 100
            
Sample Output
162000
            1
            100000
            1 2
            190000
            3
            

动态规划,注意边界的初始化,g[i][j]表示  j  个人完成 i  项工作最大利润。注意初始化的时候 g[ i ][ 0] =sum f[k]  (1<=k<=m)   g[0][i]=-inf (1<=i<=n)
g[0][0]=0;  其他的 g[i][j]=-inf;

然后状态转移方程 

g[i][j]=max(g[i-1][k]+(reward[i]-salary*(j-k))*f[i][j-k]/100-(100-f[i][j-k])*fine[i]/100,g[i][j])

#include <iostream>
#include 
<iomanip>
#define inf 1e16;

using namespace std;

double g[200][200];
int f[200][200];
int n,m,salary;
int reward[200],fine[200];



int max(int x,int y)
{
    
if (x>y) return x;
    
else
        
return y;
}


int main()
{
    
int t,i,j,k;
    cin
>>t;
    memset(f,
0,sizeof(f));
    
    
while (t--)
    
{
        
        
        cin
>>n>>m;

        
for (i=0;i<=n;i++)
            
for (j=0;j<=m;j++)
                g[i][j]
=-inf;
        
        g[
0][0]=0;

        cin
>>salary;
        salary
*=100;
        
for (i=1;i<=n;i++)
        
{
            
for (j=1;j<=m;j++)
                cin
>>f[i][j];
            
            cin
>>reward[i];
            reward[i]
*=100;
            cin
>>fine[i];
            fine[i]
*=100;
            g[i][
0]=g[i-1][0]-fine[i];
        }

        
        
for (i=1;i<=m;i++)
            g[
0][i]=-salary*i;
        
for (i=1;i<=n;i++)
            
for (j=1;j<=m;j++)
                
for (k=0;k<=j;k++)
                    g[i][j]
=max(g[i-1][k]+(reward[i]-salary*(j-k))*f[i][j-k]/100-(100-f[i][j-k])*fine[i]/100,g[i][j]);

        
double mm=-inf;
        
for (i=0;i<=m;i++)
            
if (g[n][i]>mm) mm=g[n][i];

        
int num=0;
        
int ans[200];
        
for (i=0;i<=m;i++)
            
if (g[n][i]==mm)
            
{
                ans[num]
=i;
                num
++;
            }

        
            cout
<<setiosflags(ios::fixed)<<setprecision(0);
            cout
<<mm<<endl;
        
for (i=0;i<num;i++)
        
{
            cout
<<ans[i];
            
if (i<num-1) cout<<' ';
        }

        cout
<<endl;
    }

    
return 0;
}