/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 53ms 2.996 MiB
#3 Accepted 53ms 2.969 MiB
#4 Accepted 52ms 2.961 MiB
#5 Accepted 53ms 2.969 MiB
#6 Accepted 53ms 2.996 MiB
#7 Accepted 52ms 2.961 MiB
#8 Accepted 50ms 2.969 MiB
#9 Accepted 47ms 2.91 MiB
#10 Accepted 44ms 2.965 MiB
#11 Accepted 32ms 2.227 MiB
#12 Accepted 10ms 960.0 KiB

Code

#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define endl '\n'
#define Endl '\n'

using namespace std;

const int N = 2e5 + 5;
int tc, n, m;
vector<pair<int, int>> results;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.F == b.F) {
        return a.S < b.S;
    } else {
        return a.F > b.F;
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); // cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        results.push_back({x, -1});
    }
    cin >> m;
    for (int i = 1; i <= m; i++) {
        int x;
        cin >> x;
        results.push_back({x, i});
    }

    vector<int> Ans(m);
    int cnt = 0;
    sort(results.begin(), results.end(), cmp);
    for (auto i : results) {
        ++cnt;
        if (i.S != -1) {
            Ans[i.S - 1] = cnt;
        }
    }
    for (int i = 0; i < m; i++) {
        if (i) {
            cout << " ";
        }
        cout << Ans[i];
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1049 Combined scoreboard
Contest
Brain Booster #3
Language
C++17 (G++ 13.2.0)
Submit At
2024-05-06 15:32:27
Judged At
2024-10-03 13:51:49
Judged By
Score
100
Total Time
53ms
Peak Memory
2.996 MiB