zoukankan      html  css  js  c++  java
  • 奶茶爱好者(贪心,二分图,)

    英文预备:

    second to none

    conduct a milk tea festival

    make many cups of milk tea

    savour(savor)品味,细品,享用;体味,享受。

    savor milk tea.

    题目地址:http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1011&cid=855

    分析: 
    bipartite( involving or made up of two separate parts ) graph:二分图
    因此,二分图的表示为:G=(U,V,E)。or G=(U+V,E)。

    如果|U|=|V|,即集合U和集合V的元素个数相等,该二分图称为“平衡二分图”(Balanced bipartite graph)。 

    Hall’s marriage theorem:

     Go reading 《Recreational Mathematics Magazines》

    Problems:The Mutilated(残缺的,破坏的) Chess Board

    find an unexpected connection,and discover the true power of abstract mathematics while still seeing the concrete applications in action.

    . Sometimes even classic puzzles can turn up something new and interesting.

    a set of dominos,(多米诺骨牌)

    解决: 

    #include<bits/stdc++.h>
    using namespace std;
    int n;
    //two arrays that integers in them 0<= element <=10^9
    long long a[1<<20],b[1<<20];
    
    int main()
    {
    	int t;
    	scanf("%d",&t);
    	while(t--)
    	{
    		scanf("%d",&n);
    		//begin to build an imaginary bipartite graph.
    		for(int i=0;i<n;i++) scanf("%lld%lld",a+i,b+i);
    		
    		//|U|==totu==accumulate(a,a+n,0ll).
    		long long totu=accumulate(a,a+n,0ll);
    		//|V|
    		long long totv=accumulate(b,b+n,0ll);
    		long long ans=min(totu,totv);
    		//magic codes.
    		//using Hall's marriage theorem.
    		for(int i=0;i<n;i++) ans=min(ans,totu+totv-a[i]-b[i]);
    		//all three cases can be computed in linear time. 
    		printf("%lld
    ",ans);
    	}
    	return 0;
    }
    

      

     

     
     
     
  • 相关阅读:
    从国内流程管理软件市场份额看中国BPM行业发展
    为什么流程是成功企业的关键?
    港真,到底应该选择OA还是BPM?
    hello world
    i40e网卡驱动遇到的一个问题
    suse 11 sp3编译报错问题
    linux scsi相关的一些学习笔记
    linux tcp 在timewait 状态下的报文处理
    趋势科技 redirfs模块的一个小问题
    linux 3.10 一个扇区异常可能引发的hung
  • 原文地址:https://www.cnblogs.com/dragondragon/p/11357226.html
Copyright © 2011-2022 走看看