###### Some.

[想いの奈落に落ちた哀れな一人は](o゜▽゜)o☆水平有限感谢指正毕设要紧急转CV要py交易的退役狗回复很不及时请大神们见谅…...

# 奔小康赚大钱

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7423    Accepted Submission(s): 3301

Problem Description

Input

Output

Sample Input
2 100 10 15 23

Sample Output
123

Source

Recommend
lcy   |   We have carefully selected several similar problems for you:  2063 1068 3360 1083 2444

const int maxn = 310;
const int INF = 0x3f3f3f3f;

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<malloc.h>
using namespace std;
typedef long long ll;
const int maxn = 310;
const int INF = 0x3f3f3f3f;
int nx,ny;//两边的点数
int g[maxn][maxn];//二分图描述
int slack[maxn];
bool visx[maxn],visy[maxn];
bool DFS(int x)
{
visx[x] = true;
for(int y = 1; y <= ny; y++)
{
if(visy[y])continue;
int tmp = lx[x] + ly[y] - g[x][y];
if(tmp == 0)
{
visy[y] = true;
{
return true;
}
}
else if(slack[y] > tmp)
slack[y] = tmp;
}
return false;
}
int KM()
{
memset(lx,0,sizeof(lx));
memset(ly,0,sizeof(ly));
for(int i = 1; i <= nx; i++)
{
lx[i] = -INF;
for(int j = 1; j <= ny; j++)
if(g[i][j] > lx[i])
lx[i] = g[i][j];
}
for(int x = 1; x <= nx; x++)
{
for(int i = 1; i <= ny; i++)
slack[i] = INF;
while(true)
{
memset(visx,false,sizeof(visx));
memset(visy,false,sizeof(visy));
if(DFS(x))break;
int d = INF;
for(int i = 1; i <= ny; i++)
if(!visy[i] && d > slack[i])
d = slack[i];
for(int i = 1; i <= nx; i++)
if(visx[i])
lx[i] -= d;
for(int i = 1; i <= ny; i++)
{
if(visy[i])ly[i] += d;
else slack[i] -= d;
}
}
}
int res = 0;
for(int i = 1; i <= nx; i++)
return res;
}
int main()
{
int n;
while(scanf("%d",&n) == 1)
{
for(int i = 1; i <= n; i++)
for(int j =1; j <= n; j++)
scanf("%d",&g[i][j]);
nx = ny = n;
printf("%d\n",KM());
}
return 0;
}
/**
2
100 10
15 23
**/


#### Kuhn-Munkres算法

2012-01-02 22:53:02

#### <em>Kuhn</em>_<em>Munkras</em>算法O(n^3)实现

2018年05月08日 00:00

#### 利用Kuhn-Munkras算法求最小权值匹配

2017-07-20 19:11:31

#### 匈牙利算法(Kuhn-Munkres)算法

2014-03-07 23:07:11

#### 常用算法代码

2018年05月07日 00:00

#### 吉林大学ACM代码库全集(.pdf)

2018年05月07日 00:00

#### 数学建模十大经典算法漫谈

2016-10-29 09:45:23

#### Ｋuhn-Munkres算法

2017-01-04 16:28:30

#### 连接图算法CGR（一）

2016-10-25 21:55:42

#### KM算法（完备匹配下的最大权匹配）

2016-10-24 09:22:16

## 不良信息举报

HDU 2255-奔小康赚大钱（Kuhn-Munkras算法/KM算法-完备匹配下的最大权匹配）