/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 55ms 3.023 MiB
#3 Accepted 54ms 2.969 MiB
#4 Accepted 54ms 2.898 MiB
#5 Accepted 52ms 3.047 MiB
#6 Accepted 53ms 3.031 MiB
#7 Accepted 53ms 3.078 MiB
#8 Accepted 51ms 2.965 MiB
#9 Accepted 48ms 2.965 MiB
#10 Accepted 46ms 2.965 MiB
#11 Accepted 33ms 2.285 MiB
#12 Accepted 10ms 932.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-11-11 03:34:08
Judged By
Score
100
Total Time
55ms
Peak Memory
3.078 MiB