165562025-05-06 18:04:56algoproTornyokcpp17Time limit exceeded 28/100493ms68632 KiB
// UUID: 515bcaa2-070a-4afd-b16c-d0fe31b60d22
#include <bits/stdc++.h>
using namespace std;
#define int int64_t

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
base28/100
1Accepted0/01ms316 KiB
2Time limit exceeded0/0488ms57484 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted6/61ms316 KiB
6Wrong answer0/61ms316 KiB
7Wrong answer0/432ms5508 KiB
8Wrong answer0/448ms10276 KiB
9Accepted8/8347ms40208 KiB
10Time limit exceeded0/8449ms61144 KiB
11Time limit exceeded0/5493ms58240 KiB
12Time limit exceeded0/5488ms53676 KiB
13Accepted5/5158ms18088 KiB
14Accepted5/5305ms40592 KiB
15Time limit exceeded0/5462ms61656 KiB
16Time limit exceeded0/5492ms68632 KiB
17Time limit exceeded0/5486ms56968 KiB
18Time limit exceeded0/5490ms56992 KiB
19Time limit exceeded0/5492ms54940 KiB
20Time limit exceeded0/5488ms54172 KiB
21Time limit exceeded0/5492ms54172 KiB
22Time limit exceeded0/5486ms52380 KiB