230262026-01-16 10:51:34Gervid20G (40 pont)cpp17Elfogadva 40/4016ms1868 KiB
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits.h>
#include <algorithm>
#include <math.h>
#include <array>

using namespace std;
using ll = long long;

signed main()
{
	iostream::sync_with_stdio(0);
	cin.tie(0);

	int n, q;
	cin >> n >> q;
	vector<int> houses(n);
	for (int i = 0; i < n; i++) cin >> houses[i];

	vector<array<int, 2>> h; //ascending in heights by leaving out elements {height, origIdx}
	h.reserve(n);
	h.push_back({houses[0], 0});
	for (int i = 1; i < n; i++) {
		if (houses[i] <= h.back()[0]) continue;
		h.push_back({ houses[i], i });
	}

	while (q--) {
		int m;
		cin >> m;
		array<int, 2> v = { m, INT_MAX };
		cout << lower_bound(h.begin(), h.end(), v).operator*()[1] + 1 << '\n';
	}
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base40/40
1Elfogadva0/01ms316 KiB
2Elfogadva0/013ms1016 KiB
3Elfogadva2/21ms500 KiB
4Elfogadva2/21ms316 KiB
5Elfogadva2/21ms316 KiB
6Elfogadva2/21ms352 KiB
7Elfogadva3/31ms428 KiB
8Elfogadva3/316ms1592 KiB
9Elfogadva3/316ms1596 KiB
10Elfogadva3/316ms1608 KiB
11Elfogadva4/416ms1596 KiB
12Elfogadva4/416ms1844 KiB
13Elfogadva4/416ms1660 KiB
14Elfogadva4/416ms1868 KiB
15Elfogadva4/416ms1600 KiB