九度oj1170:找最小数

<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
****************************************************************/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值