-
Notifications
You must be signed in to change notification settings - Fork 0
/
SCTDL057.cpp
39 lines (38 loc) · 886 Bytes
/
SCTDL057.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* @file SCTDL057.cpp
* @author your name ([email protected])
* @brief Given n elements array A that does not contain
* 2 same elements.
* Find K = Floor(X).
* K is maximum element of A less than of equal to X
* @version 0.1
* @date 2023-06-13
*
* @copyright Copyright (c) 2023
*
*/
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
int main()
{
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// int t;
// cin >> t;
// while (t--)
// {
int n{7}, x{10};
// cin >> n >> x;
vector<long long> a = {1, 2, 8, 10, 11, 12, 19};
// for (int i = 0; i < n; i++)
// cin >> a[i];
a[n + 1] = 1e18;
int ans = lower_bound(a.begin(), a.end() - 1, x) - a.begin();
if (a[ans] != x)
ans--;
if (ans != -1)
ans++;
cout << ans << endl;
// }
}