zoukankan      html  css  js  c++  java
  • 【Codeforces Round #429 (Div. 2) C】Leha and Function

    Link:http://codeforces.com/contest/841/problem/C

    Description

    Solution

    看到最大的和最小的对应,第二大的和第二小的对应。
    贪心,排个序。

    NumberOf WA


    Reviw


    Code

    #include <bits/stdc++.h>
    using namespace std;
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define LL long long
    #define rep1(i,a,b) for (int i = a;i <= b;i++)
    #define rep2(i,a,b) for (int i = a;i >= b;i--)
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define ms(x,y) memset(x,y,sizeof x)
    #define ri(x) scanf("%d",&x)
    #define rl(x) scanf("%lld",&x)
    #define rs(x) scanf("%s",x+1)
    #define oi(x) printf("%d",x)
    #define ol(x) printf("%lld",x)
    #define oc putchar(' ')
    #define os(x) printf(x)
    #define all(x) x.begin(),x.end()
    #define Open() freopen("F:\rush.txt","r",stdin)
    #define Close() ios::sync_with_stdio(0)
    
    typedef pair<int,int> pii;
    typedef pair<LL,LL> pll;
    
    const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
    const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
    const double pi = acos(-1.0);
    const int N = 2e5;
    
    struct abc{
        int x,id;
    };
    
    abc a[N+10],b[N+10];
    int m,ans[N+10];
    
    bool cmp1(abc a,abc b){
        return a.x > b.x;
    }
    
    bool cmp2(abc a,abc b){
        return a.x < b.x;
    }
    
    int main(){
        //Open();
        //Close();
        ri(m);
        rep1(i,1,m){
            ri(a[i].x);
            a[i].id = i;
        }
        rep1(i,1,m){
            ri(b[i].x);
            b[i].id = i;
        }
        sort(a+1,a+1+m,cmp1);
        sort(b+1,b+1+m,cmp2);
        rep1(i,1,m){
            ans[b[i].id] = a[i].x;
        }
        rep1(i,1,m){
            oi(ans[i]);
            if (i==m)
                puts("");
            else
                oc;
        }
        return 0;
    }
  • 相关阅读:
    简单的结账功能(可用于各种结账)
    有关菜单进行“估清”的功能
    在线客服~~
    在windows下安装GIT
    GIT之二 基础篇(2)
    简单模仿javascript confirm方法的例子
    微信公众平台开发 第三篇
    微信公众平台开发 第二篇
    微信公众平台开发 第一篇
    GIT之二 基础篇(1)
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626111.html
Copyright © 2011-2022 走看看