15442022-11-22 23:54:31TomaSajtHáromszögekcpp14Accepted 40/4057ms4600 KiB
#include <bits/stdc++.h>
#define speed ios::sync_with_stdio(0);cin.tie(0)
using namespace std;

int main() {
    speed;
    int n, q;
    cin >> n >> q;
    vector<int> v(n);
    for (auto& a : v) cin >> a;
    sort(v.begin(), v.end());
    while (q--) {
        int a, b;
        cin >> a >> b;
        int l = abs(a - b);
        int r = a + b;
        auto lit = upper_bound(v.begin(), v.end(), l);
        auto rit = lower_bound(v.begin(), v.end(), r);
        cout << rit - lit << '\n';
    }
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1828 KiB
2Accepted0/02ms2056 KiB
3Accepted0/06ms2424 KiB
4Accepted4/43ms2440 KiB
5Accepted2/23ms2640 KiB
6Accepted1/146ms3460 KiB
7Accepted1/141ms3452 KiB
8Accepted2/241ms3660 KiB
9Accepted2/241ms3864 KiB
10Accepted1/148ms4056 KiB
11Accepted1/146ms4060 KiB
12Accepted2/248ms4056 KiB
13Accepted2/246ms4180 KiB
14Accepted1/154ms4272 KiB
15Accepted1/148ms4264 KiB
16Accepted1/148ms4264 KiB
17Accepted1/143ms4272 KiB
18Accepted1/141ms4304 KiB
19Accepted2/241ms4336 KiB
20Accepted2/243ms4588 KiB
21Accepted3/343ms4476 KiB
22Accepted5/552ms4540 KiB
23Accepted5/557ms4600 KiB