84802024-01-17 15:34:56anon20G (40 pont)cpp17Accepted 40/4032ms7240 KiB
#include <bits/stdc++.h>
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long long ll;
int main() {
    FastIO;
    ll i, m, N, Q;
    cin >> N >> Q;
    vector<ll> T(N);
    for(i = 0; i < N; i++)
        cin >> T[i];
    map<ll, vector<ll>> M;
    for(i = 0; i < Q; i++) {
        cin >> m;
        if(M.find(m) == M.end())
            M.insert({ m, {} });
        M[m].push_back(i);
    }
    vector<ll> ans(Q, N);
    auto it = M.begin();
    for(i = 0; i < N && it != M.end(); i++) {
        auto b = M.lower_bound(T[i]);
        while((b == M.end() && it != M.end()) || it->first < b->first) {
            for(const auto &x : it->second)
                ans[x] = i + 1;
            it++;
        }
    }
    for(const auto &x : ans)
        cout << x << '\n';
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1832 KiB
2Accepted0/032ms5596 KiB
3Accepted2/23ms2348 KiB
4Accepted2/23ms2544 KiB
5Accepted2/23ms2808 KiB
6Accepted2/24ms3172 KiB
7Accepted3/34ms3280 KiB
8Accepted3/326ms6708 KiB
9Accepted3/326ms6716 KiB
10Accepted3/323ms5672 KiB
11Accepted4/430ms6972 KiB
12Accepted4/423ms7184 KiB
13Accepted4/429ms7240 KiB
14Accepted4/417ms5268 KiB
15Accepted4/417ms5308 KiB