/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 496.0 KiB
#2 Accepted 52ms 3.168 MiB
#3 Accepted 51ms 3.363 MiB
#4 Accepted 51ms 3.254 MiB
#5 Accepted 51ms 3.25 MiB
#6 Accepted 56ms 3.215 MiB
#7 Accepted 50ms 2.922 MiB
#8 Accepted 50ms 3.164 MiB
#9 Accepted 53ms 3.09 MiB
#10 Accepted 44ms 3.141 MiB
#11 Accepted 41ms 3.227 MiB
#12 Accepted 10ms 1.145 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-11-11 03:31:02
Judged By
Score
100
Total Time
56ms
Peak Memory
3.363 MiB