日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內(nèi)最全IT社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > 互聯(lián)網(wǎng) > POJ 3469 Dual Core CPU

POJ 3469 Dual Core CPU

來源:程序員人生   發(fā)布時間:2014-10-02 08:00:01 閱讀次數(shù):2571次

一堆任務(wù)分配到2個不同的芯片上運行,一個任務(wù)在不同芯片上運行的時間不一樣,有一些任務(wù)組如果分配到不同的芯片上運行會產(chǎn)生額外的時間....

用最小的費用將不同對象劃分到兩個集合 , 最小割問題 .  

建圖:

用源點匯點代表兩個芯片

對某個任務(wù) , 在 A 芯片上運行時間 t1 . 則從源點連一條 到 這個任務(wù)容量為 t1 的邊 . 對 B 芯片上運行時間同理

如果兩個任務(wù)間有聯(lián)系,著再倆個任務(wù)間連邊.

原問題就轉(zhuǎn)化成了, 將圖分成兩部分,所切割的容量最少.

最小割==最大流 isap 解決


Dual Core CPU
Time Limit: 15000MS   Memory Limit: 131072K
Total Submissions: 19127   Accepted: 8263
Case Time Limit: 5000MS

Description

As more and more computers are equipped with dual core CPU, SetagLilb, the Chief Technology Officer of TinySoft Corporation, decided to update their famous product - SWODNIW.

The routine consists of N modules, and each of them should run in a certain core. The costs for all the routines to execute on two cores has been estimated. Let's define them as Ai and Bi. Meanwhile, M pairs of modules need to do some data-exchange. If they are running on the same core, then the cost of this action can be ignored. Otherwise, some extra cost are needed. You should arrange wisely to minimize the total cost.

Input

There are two integers in the first line of input data, N and M (1 ≤ N ≤ 20000, 1 ≤ M ≤ 200000) .
The next N lines, each contains two integer, Ai and Bi.
In the following M lines, each contains three integers: abw. The meaning is that if module a and module b don't execute on the same core, you should pay extra w dollars for the data-exchange between them.

Output

Output only one integer, the minimum total cost.

Sample Input

3 1 1 10 2 10 10 3 2 3 1000

Sample Output

13

Source

POJ Monthly--2007.11.25, Zhou Dong

[Submit]   [Go Back]   [Status]   [Discuss]




#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn=20200; const int maxm=600300; const int INF=0x3f3f3f3f; struct Edge { int to,next,cap,flow; }edge[maxm]; int Size,Adj[maxn]; int gap[maxn],dep[maxn],pre[maxn],cur[maxn]; void init() { Size=0; memset(Adj,-1,sizeof(Adj)); } void addedge(int u,int v,int w,int rw=0) { edge[Size].to=v; edge[Size].cap=w; edge[Size].next=Adj[u]; edge[Size].flow=0; Adj[u]=Size++; edge[Size].to=u; edge[Size].cap=rw; edge[Size].next=Adj[v]; edge[Size].flow=0; Adj[v]=Size++; } int sap(int start,int end,int N) { memset(gap,0,sizeof(gap)); memset(dep,0,sizeof(dep)); memcpy(cur,Adj,sizeof(Adj)); int u=start; pre[u]=-1;gap[0]=N; int ans=0; while(dep[start]<N) { if(u==end) { int Min=INF; for(int i=pre[u];~i;i=pre[edge[i^1].to]) if(Min>edge[i].cap-edge[i].flow) Min=edge[i].cap-edge[i].flow; for(int i=pre[u];~i;i=pre[edge[i^1].to]) { edge[i].flow+=Min; edge[i^1].flow-=Min; } u=start; ans+=Min; continue; } bool flag=false; int v; for(int i=cur[u];~i;i=edge[i].next) { v=edge[i].to; if(edge[i].cap-edge[i].flow&&dep[v]+1==dep[u]) { flag=true; cur[u]=pre[v]=i; break; } } if(flag) { u=v; continue; } int Min=N; for(int i=Adj[u];~i;i=edge[i].next) { if(edge[i].cap-edge[i].flow&&dep[edge[i].to]<Min) { Min=dep[edge[i].to]; cur[u]=i; } } gap[dep[u]]--; if(!gap[dep[u]]) return ans; dep[u]=Min+1; gap[dep[u]]++; if(u!=start) u=edge[pre[u]^1].to; } return ans; } int n,m; int main() { while(scanf("%d%d",&n,&m)!=EOF) { init(); for(int i=1;i<=n;i++) { int a,b; scanf("%d%d",&a,&b); addedge(0,i,a); addedge(i,n+1,b); } for(int i=0;i<m;i++) { int u,v,w; scanf("%d%d%d",&u,&v,&w); addedge(u,v,w,w); } printf("%d ",sap(0,n+1,n+2)); } return 0; }



生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 免费aaaaaa少妇动态图美女 | 一区中文字幕 | 久久国产电影 | 99久久精品国产毛片 | 精品久久久久久久久久久久 | 亚洲国产成人精品女人 | 亚洲精品99久久久久中文字幕 | 久久综合五月天 | 免费a级| 国产精品久久综合 | 成人在线免费观看视频 | 亚洲欧美另类在线 | jiyouzz国产精品久久 | 男人天堂av网 | 日韩中文字幕精品 | 国产剧情一区二区三区 | 99久久99久久精品国产片果冻 | 日韩一区二区三区在线播放 | 久久国产亚洲精品 | 在线看日韩av | 成人午夜精品 | 久久99成人 | 全免一级毛片 | 国产精品日韩欧美 | 国产精品色一区二区三区 | 国产福利影院 | 亚洲成人av电影 | 可以看黄色的网站 | 国产精品久久一区 | 国产一区二区免费在线 | 久久综合成人精品亚洲另类欧美 | 一区二区三区高清不卡 | 亚洲 自拍 另类 欧美 丝袜 | 欧美在线一区二区三区四区 | 九九久久精品一区二区三区 | 亚洲一区二三区 | 国产欧美精品一区二区三区 | 精品九九 | 国产精品一区二区三 | 国产精品一区在线观看你懂的 | 日本一区二区三区免费在线 |