I can do it!

Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)

Total Submission(s): 1022    Accepted Submission(s): 475

Problem Description
Given n elements, which have two properties, say Property A and Property B. For convenience, we use two integers Ai and Bi to measure the two properties.


Your task is, to partition the element into two sets, say Set A and Set B , which minimizes the value of max(x∈Set A) {Ax}+max(y∈Set B) {By}.

See sample test cases for further details.
 
Input
There are multiple test cases, the first line of input contains an integer denoting the number of test cases.

For each test case, the first line contains an integer N, indicates the number of elements. (1 <= N <= 100000)

For the next N lines, every line contains two integers Ai and Bi indicate the Property A and Property B of the ith element. (0 <= Ai, Bi <= 1000000000)
 
Output
For each test cases, output the minimum value.
 
Sample Input
1
3
1 100
2 100
3 1
 
Sample Output
Case 1: 3
 
Author
HyperHexagon
 
Source
 
Recommend
zhengfeng   |   We have carefully selected several similar problems for you:  3553 3545 3546 3547 3548

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct node
{
int a,b;
}num[1000100];
int cmp(node s1,node s2)
{
return s1.a>s2.a;
}
int main()
{
int t,n;
scanf("%d",&t);
int k=1;
while(t--)
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d%d",&num[i].a,&num[i].b);
int maxx1=0,ans=0x3f3f3f3f;
sort(num+1,num+1+n,cmp);
num[0].b=0;
num[n+1].a=0;
for(int i=1;i<=n+1;i++)
{
maxx1=max(maxx1,num[i-1].b);
ans=min(ans,num[i].a+maxx1);
}
printf("Case %d: %d\n",k++,ans);
}
return 0;
}

最新文章

  1. 设置UITableView的separatorInset值为UIEdgeInsetsZero,分隔线不最左端显示的问题
  2. WCF基础教程之异常处理:你的Try..Catch语句真的能捕获到异常吗?
  3. php:获取浏览器的版本信息
  4. python web框架——初识tornado
  5. vmware12安装vmtools
  6. py变量
  7. unity3d的四元数 Quaternion
  8. nginx日志文件切割
  9. lighttpd mod_status模块
  10. javaWeb实现使用邮箱邮件找回密码功能
  11. linux下mysql环境支持中文配置步骤
  12. Kienct与Arduino学习笔记(2) 深度图像与现实世界的深度图的坐标
  13. point类型&#183;
  14. webpack2.x基础属性讲解(一)
  15. 一个只有99行代码的JS流程框架
  16. 【java学习笔记】文件操作
  17. python自学日志--基础篇(1)
  18. Leetcode_145_Binary Tree Postorder Traversal
  19. EL语言表达式 (一)【语法和特点】
  20. caffe模型参数解释

热门文章

  1. asp.net-DirectoryEntry基本操作入门
  2. Android内存优化之封装九宫格
  3. iOS开发自己定义键盘回车键Return Key
  4. 第二次phython作业
  5. nyoj 628 小媛在努力 【搜索】
  6. kentico中的urls
  7. WPF获取和设置鼠标位置与progressbar的使用方法
  8. ThinkPHP新建控制器
  9. zzulioj--1708--01串也疯狂之光棍也有伴(dp)
  10. Resolving Problems installing the Java JCE Unlimited Strength Jurisdiction Policy Files package--转