码迷,mamicode.com
首页 > 其他好文 > 详细

CodeForces 840A - Leha and Function | Codeforces Round #429 (Div. 1)

时间:2017-08-20 15:43:39      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:round   space   ++   int   class   printf   bit   clu   amp   

/*
CodeForces 840A - Leha and Function [ 贪心 ]  |  Codeforces Round #429 (Div. 1)
A越大,B越小,越好
*/
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
int a[N], b[N], c[N], n;
int aa[N], bb[N];
bool cmp1(int x, int y) {
    return a[x] > a[y];
}
bool cmp2(int x, int y) {
    return b[x] < b[y];
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
    for (int i = 1; i <= n; i++) aa[i] = bb[i] = i;
    sort(aa+1, aa+n+1, cmp1);
    sort(bb+1, bb+n+1, cmp2);
    for (int i = 1; i <= n; i++) c[bb[i]] = a[aa[i]];
    for (int i = 1; i < n; i++) printf("%d ", c[i]);
    printf("%d\n", c[n]);
}

  

CodeForces 840A - Leha and Function | Codeforces Round #429 (Div. 1)

标签:round   space   ++   int   class   printf   bit   clu   amp   

原文地址:http://www.cnblogs.com/nicetomeetu/p/7399986.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!