标签:
Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 1010 Accepted Submission(s): 471
题解:题意好难理解啊,好像是给你一些元素,这些元素有两个性质,把这两个性质分成两个集合,然后找A几何中最大值加上B集合中最大值的最小化值;可以用贪心来找。。。
代码:
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; #define mem(x,y) memset(x,y,sizeof(x)) #define T_T while(T--) #define SI(x) scanf("%d",&x) #define SL(x) scanf("%lld",&x) typedef long long LL; const int INF=0x3f3f3f3f; const int MAXN=100010; struct Node{ int a,b; friend bool operator < (Node x,Node y){ return x.a>y.a; } }; Node dt[MAXN]; int main(){ int T,N,kase=0; SI(T); T_T{ SI(N); for(int i=0;i<N;i++)SI(dt[i].a),SI(dt[i].b); sort(dt,dt+N); int A,B=0,ans=INF; for(int i=0;i<N;i++){ ans=min(ans,B+dt[i].a); B=max(dt[i].b,B); } printf("Case %d: %d\n",++kase,ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/5060965.html