首页 > 其他 > 详细

HDU 3552 I can do it!

时间:2015-10-07 20:20:58      阅读:277      评论:0      收藏:0      [点我收藏+]

脑洞题。http://blog.csdn.net/dgq8211/article/details/7748078

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

struct abc
{
    int A,B;
}x[100010];
int T,N;
int Max[100010];

bool cmp(const abc&a,const abc&b)
{
    return a.A<b.A;
}

int main()
{
    scanf("%d",&T);
    for(int t=1;t<=T;t++)
    {
        scanf("%d",&N);
        for(int i=0;i<N;i++)
            scanf("%d%d",&x[i].A,&x[i].B);
        sort(x,x+N,cmp);
        memset(Max,0,sizeof Max);
        int ans=0x7FFFFFFF;
        Max[N-1]=x[N-1].B;
        for(int i=N-2;i>=0;i--)
            Max[i]=max(Max[i+1],x[i].B);
        for(int i=0;i<N;i++)
            ans=min(ans,x[i].A+Max[i+1]);
        printf("Case %d: %d\n",t,ans);
    }
    return 0;
}

 

HDU 3552 I can do it!

原文:http://www.cnblogs.com/zufezzt/p/4859167.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!