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

Posted nicetomeetu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeForces 840A - Leha and Function | Codeforces Round #429 (Div. 1)相关的知识,希望对你有一定的参考价值。

/*
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)的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces 794F. Leha and security system 线段树

Codeforces 841D Leha and another game about graph - 差分

[Codeforces 841C]Leha and Function

CodeForces841C. Leha and Function(Codeforces Round #429 (Div. 2))

CodeForces 840B - Leha and another game about graph | Codeforces Round #429(Div 1)

Codeforces 841 D - Leha and another game about graph