<dl style="margin: 0px 0px 20px; padding: 0px; color: rgb(51, 51, 51); font-family: 'MicroSoft Yahei', Helvetica, Arial, Georgia, Simsun; font-size: 14px; line-height: 25px;"><dt style="margin: 0px 0px 10px; padding: 0px; font-size: 16px;"><strong>题目描述:</strong></dt><dd style="margin: 0px; padding: 0px;"><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px;">第一行输入一个数n,1 <= n <= 1000,下面输入n行数据,每一行有两个数,分别是x y。输出一组x y,该组数据是所有数据中x最小,且在x相等的情况下y最小的。 </p></dd></dl><dl style="margin: 0px 0px 20px; padding: 0px; color: rgb(51, 51, 51); font-family: 'MicroSoft Yahei', Helvetica, Arial, Georgia, Simsun; font-size: 14px; line-height: 25px;"><dt style="margin: 0px 0px 10px; padding: 0px; font-size: 16px;"><strong>输入:</strong></dt><dd style="margin: 0px; padding: 0px;"><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px;">输入有多组数据。
每组输入n,然后输入n个整数对。<a target=_blank href="http://ac.jobdu.com/problem.php?pid=1170">http://ac.jobdu.com/problem.php?pid=1170</a></p></dd></dl><dl style="margin: 0px 0px 20px; padding: 0px; color: rgb(51, 51, 51); font-family: 'MicroSoft Yahei', Helvetica, Arial, Georgia, Simsun; font-size: 14px; line-height: 25px;"><dt style="margin: 0px 0px 10px; padding: 0px; font-size: 16px;"><strong>输出:</strong></dt><dd style="margin: 0px; padding: 0px;"><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px;">输出最小的整数对。</p></dd></dl><dl style="margin: 0px 0px 20px; padding: 0px; color: rgb(51, 51, 51); font-family: 'MicroSoft Yahei', Helvetica, Arial, Georgia, Simsun; font-size: 14px; line-height: 25px;"><dt style="margin: 0px 0px 10px; padding: 0px; font-size: 16px;"><strong>样例输入:</strong></dt><dd style="margin: 0px; padding: 0px;"><pre style="white-space: pre-wrap;">5
3 3
2 2
5 5
2 1
3 6
样例输出:
-
2 1
#include <iostream>
#include <algorithm>
using namespace std;
int a[1005],b[1005];
struct sf
{
int a,b;
}s[1005];
int cmp(sf s1,sf s2)
{
if(s1.a<s2.a) return 1;
else if(s1.a==s2.a && s1.b<s2.b) return 1;
return 0;
}
int main()
{
int n,i,x,y;
while(cin>>n)
{
for(i=0;i<n;i++)
{
cin>>s[i].a>>s[i].b;
}
sort(s,s+n,cmp);
cout<<s[0].a<<" "<<s[0].b<<endl;
}
return 0;
}
/**************************************************************
Problem: 1170
User: cucumber王子
Language: C++
Result: Accepted
Time:10 ms
Memory:1536 kb
****************************************************************/