165592025-05-06 18:12:05algoproTornyokcpp17Time limit exceeded 41/100503ms65512 KiB
// UUID: 6a49b89b-0610-4f4c-8928-dcdb107f67cf
#include <bits/stdc++.h>
using namespace std;

int32_t main() {
    cin.tie(0), ios::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<int> b(n), h(k);
    for (int& x : b) cin >> x;
    for (int& x : h) cin >> x;
    b.push_back(2e9);

    map<int, int> hans;
    stack<int> s;
    s.push(2e9 + 1);
    for (int x : b) {
        int i = 1;
        while (s.top() <= x) {
            hans[s.top()] = max(hans[s.top()], i);
            s.pop();
            i++;
        }
        s.push(x);
    }
    hans[0] = 0;
    hans[2e9] = 0;

    vector<int> hs, vals;
    for (auto [x, y] : hans) {
        hs.push_back(x);
        vals.push_back(y);
    }
    for (int i = 1; i < vals.size(); i++) {
        vals[i] = max(vals[i], vals[i - 1]);
    }
    for (int i = 0; i < k; i++) {
        int j = upper_bound(hs.begin(), hs.end(), h[i]) - hs.begin() - 1;
        cout << vals[j] << " ";
    }
    cout << "\n";
}
SubtaskSumTestVerdictTimeMemory
base41/100
1Accepted0/01ms500 KiB
2Time limit exceeded0/0486ms46428 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted6/61ms316 KiB
6Wrong answer0/61ms316 KiB
7Wrong answer0/429ms3932 KiB
8Wrong answer0/446ms6656 KiB
9Accepted8/8307ms25516 KiB
10Accepted8/8310ms40452 KiB
11Time limit exceeded0/5503ms55212 KiB
12Time limit exceeded0/5492ms42472 KiB
13Accepted5/5122ms11888 KiB
14Accepted5/5203ms25876 KiB
15Accepted5/5335ms40484 KiB
16Time limit exceeded0/5453ms45224 KiB
17Time limit exceeded0/5503ms49568 KiB
18Time limit exceeded0/5503ms45032 KiB
19Time limit exceeded0/5479ms40684 KiB
20Time limit exceeded0/5490ms65268 KiB
21Time limit exceeded0/5481ms65512 KiB
22Time limit exceeded0/5488ms65512 KiB