Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- by: senb1
- */
- #include <bits/stdc++.h>
- #define ll long long
- #define all(x) x.begin(), x.end()
- #define fr first
- #define sc second
- #define mk make_pair
- using namespace std;
- const ll mod = 1e3;
- const ll maxn = 1e6 + 5;
- const ll inf = 1e9 + 6;
- ll binpow(ll a, ll b, ll mod) {
- ll res = 1;
- while (b > 0) {
- if (b & 1)
- res = res * a % mod;
- a = a * a;
- b >>= 1;
- }
- return res;
- }
- void solve() {
- int n, q;
- cin >> n >> q;
- vector<int> dragon(n);
- for (int i = 0; i < n; i++) {
- cin >> dragon[i];
- }
- while (q--) {
- int pos, s, ans = 0;
- cin >> pos >> s;
- pos--;
- if (s > dragon[pos]) {
- int l = pos - 1, r = pos + 1;
- ans = 1;
- while (s > dragon[l] and l >= 0) {
- ans++;
- l--;
- }
- while (s > dragon[r] and r < n) {
- ans++;
- r++;
- }
- }
- cout << ans << "\n";
- }
- }
- /*
- 5 3
- 4 2 5 3 1
- 2 5
- 3 4
- 5 4
- */
- int main() {
- ios::sync_with_stdio(0);
- cin.tie(0);
- int t = 1;
- // cin >> t;
- while (t--)
- solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement