/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 37ms 3.141 MiB
#3 Accepted 37ms 3.043 MiB
#4 Accepted 37ms 3.137 MiB
#5 Accepted 38ms 2.957 MiB
#6 Accepted 37ms 3.0 MiB
#7 Accepted 36ms 3.289 MiB
#8 Accepted 33ms 3.0 MiB
#9 Accepted 31ms 3.0 MiB
#10 Accepted 29ms 3.0 MiB
#11 Accepted 24ms 3.152 MiB
#12 Accepted 7ms 1.109 MiB

Code

// BISMILLAH

#include "bits/stdc++.h"

#define fastIO std::ios::sync_with_stdio(0);std::cin.tie(0)
#define ll long long int
#define flush fflush(stdout)
// #define int ll

using pii = std::pair<int,int>;

const int MOD = 1000000007;
// const int MOD = 998244353;
const int mxN = 500005, inf = 1000000005;

signed main() {
	// fastIO;
	int testCases=1;
	// scanf("%lld",&testCases);
	// std::cin >> testCases;
	
	for (int T = 1; T <= testCases; T++) {
        int N;
        scanf("%d", &N);
        std::vector<int> a(N);
        for (auto &i : a) scanf("%d",&i);
        sort(a.begin(), a.end());
        std::vector<pii> al;
        scanf("%d", &N);
        for (int i = 0,x; i < N; i++) {
            scanf("%d", &x);
            al.push_back({x, i});
        }
        sort(al.begin(), al.end(), [](pii a, pii b){
            if (a.first == b.first) return a.second < b.second;
            return a.first > b.first;
        });
        int ans[N];
        for (auto i : al) {
            int cur = i.first;
            auto it = lower_bound(a.begin(), a.end(), cur);
            int pos = a.end() - it + 1;
            ans[i.second] = pos;
            a.push_back(inf);
        }
        for (int i = 0; i < N; i++) {
            printf("%d ", ans[i]);
        }
    }
	
	return 0;
}

/*

*/

Information

Submit By
Type
Submission
Problem
P1049 Combined scoreboard
Language
C++17 (G++ 13.2.0)
Submit At
2024-05-07 10:15:54
Judged At
2024-05-07 10:15:54
Judged By
Score
100
Total Time
38ms
Peak Memory
3.289 MiB