codeforces 1060 D. Social Circles

题意:略。

将li,ri排序,然后大的和大的取max,就行。

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include <set>
#include 
#include 
#include 
#define mkp make_pair
#define err cout<<"err"<using namespace std;
const double EPS=1e-8;
typedef long long lon;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const lon SZ=100010,SSZ=SZ*SZ,APB=4,one=1;
const lon INF=0x3f3f3f3f,mod=1000000007;
lon n,a[SZ],b[SZ];

void init()
{
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>a[i]>>b[i];
    }
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
    lon res=n;
    for(int i=1;i<=n;++i)
    {
        res+=max(a[i],b[i]);
    }
    cout<endl;
}

void work()
{
    
}

void release()
{
    
}

int main()
{
    std::ios::sync_with_stdio(0);
    //freopen("d:\\1.txt","r",stdin);
    lon casenum;
    //cin>>casenum;
    //cout<//for(lon tim=1;tim<=casenum;++tim)
    //for(lon tim=1;cin>>n;++tim)
    {
        //cout<<"Case #"<
        init();
        work();
        release();
    }
    return 0;
}

 

转载于:https://www.cnblogs.com/gaudar/p/11549841.html

你可能感兴趣的:(codeforces 1060 D. Social Circles)