Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Mehul Chaturvedi
- Time Taken: 5min 21 sec
- */
- #include <bits/stdc++.h>
- using namespace std;
- using ll = long long;
- using ld = long double;
- using pll = pair<ll, ll>;
- #define mp make_pair
- #define all(x) (x).begin(), (x).end()
- #define f first
- #define s second
- #define vll vector<long long>
- #define vvll vector<vector<ll>>
- #define vset(v, n, val) v.clear(); v.resize(n, val)
- #define INF 4557430888798830399ll
- #define fr(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
- #define rep(i, n) for (int i = 0, _n = (n); i < _n; i++)
- #define repr(i, n) for (int i = n; i >= 0; i--)
- #define frr(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
- #define trav(a, x) for(auto& a : x)
- #define fil(ar, val) memset(ar, val, sizeof(ar))
- const ll MOD = 1e9 + 7;
- void solve() {
- ll n; cin >> n;
- vll a(n, 0);
- rep(i, n) cin >> a[i];
- ll h; cin >> h;
- ll ind1 = lower_bound(all(a), h) - a.begin();
- if (ind1 == n || a[ind1] != h) {
- cout << 0 << '\n';
- return;
- }
- ll ind2 = upper_bound(all(a), h) - a.begin();
- cout << ind2 - ind1 << '\n';
- return;
- }
- int main(int argc , char ** argv) {
- ios_base::sync_with_stdio(false) ;
- cin.tie(NULL) ;
- ll t = 1;
- while (t--) {
- solve();
- }
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment