/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 195ms 5.992 MiB
#3 Accepted 199ms 5.863 MiB
#4 Accepted 206ms 5.984 MiB
#5 Accepted 199ms 5.828 MiB
#6 Accepted 188ms 5.902 MiB
#7 Accepted 138ms 3.859 MiB
#8 Accepted 96ms 3.148 MiB
#9 Accepted 58ms 3.051 MiB
#10 Accepted 33ms 2.934 MiB
#11 Accepted 71ms 2.012 MiB
#12 Accepted 17ms 1.027 MiB

Code

#include <bits/stdc++.h>
#include <iostream>
using namespace std;

typedef long long ll;
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define mp make_pair
#define pq priority_queue<int>
#define pi pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define PI acos(-1)
const int M = 1e9 + 7;
ll binExp(ll a, ll b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = res * a;
        a *= a;
        b /= 2;
    }
    return res;
}
ll gcd(ll a, ll b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b) {
    return (a / gcd(a, b)) * b;
}
void solve() {
    int n, m;
    cin >> n;
    vector<int> v1(n);
    f(i, n) cin >> v1[i];
    cin >> m;
    map<int, int> first;
    vector<int> v2(m), v3, v, v4;
    map<int, int> mp;
    f(i, m) cin >> v2[i];
    v, v4 = v1;
    f(i, m) v, v4.push_back(v2[i]);
    sort(all(v));
    v4 = v2;
    sort(all(v4));
    f(i, n) first[v1[i]]++;
    // for (auto a : v,v4)
    //     cout << a << ' ';
    v3 = v1;
    sort(all(v3));
    f(i, m) {
        int x = v2[i];
        ll temp =
            n - (upper_bound(all(v3), x) - v3.begin());  // x theke boro in v
        // cout << temp << '\n';
        ll sec = m - (upper_bound(all(v4), x) - v4.begin());
        // cout << temp << ' ' << sec << ' ' << mp[x] << '\n';
        cout << temp + sec + mp[x] + first[x] + 1 << ' ';
        mp[x]++;
    }
}
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1049 Combined scoreboard
Contest
Brain Booster #3
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-06 15:44:42
Judged At
2024-10-03 13:51:33
Judged By
Score
100
Total Time
206ms
Peak Memory
5.992 MiB