165142025-05-05 22:27:31algoproTornyokcpp17Wrong answer 0/100500ms31892 KiB
// UUID: 7f05ca3d-bc92-4575-b5f7-5dbf7829bbca
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, q;
	cin >> n >> q;
	vector<int> sor(n), lis(n, INT_MAX), eloz(n, -1), st, lis_in_pos(n, -1);

	cout << 1 << endl;

	for (int i = 0; i < n; i++){
		cin >> sor[i];
		while(!st.empty() && sor[st.back()] < sor[i]) st.pop_back();
		if (!st.empty()) eloz[i] = st.back();
		st.push_back(i);
	}

	cout << 1 << endl;

	for (int i = n - 1; i >= 0; i--){
		if (lis_in_pos[i] == -1) lis_in_pos[i] = 0;
		if (eloz[i] != -1) lis_in_pos[eloz[i]] = lis_in_pos[i] + 1;
		lis[lis_in_pos[i]] = min(lis[lis_in_pos[i]], sor[i]);
	}
	for (int x : lis) cout << x << " ";
	cout << endl;

	for (int i = 0; i < q; i++){
		int a;
		cin >> a;
		cout << lower_bound(lis.begin(), lis.end(), a) - lis.begin() + 1 << " ";
	}

}
SubtaskSumTestVerdictTimeMemory
base0/100
1Wrong answer0/01ms316 KiB
2Time limit exceeded0/0486ms26416 KiB
3Wrong answer0/21ms500 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/62ms316 KiB
6Wrong answer0/61ms316 KiB
7Wrong answer0/435ms2452 KiB
8Wrong answer0/464ms3912 KiB
9Wrong answer0/8214ms13712 KiB
10Wrong answer0/8319ms20900 KiB
11Time limit exceeded0/5485ms25652 KiB
12Time limit exceeded0/5483ms25552 KiB
13Wrong answer0/5119ms6708 KiB
14Wrong answer0/5247ms14248 KiB
15Wrong answer0/5397ms21220 KiB
16Time limit exceeded0/5490ms25908 KiB
17Time limit exceeded0/5481ms25756 KiB
18Time limit exceeded0/5500ms25908 KiB
19Time limit exceeded0/5485ms25652 KiB
20Time limit exceeded0/5485ms31380 KiB
21Time limit exceeded0/5488ms31892 KiB
22Time limit exceeded0/5486ms31636 KiB