19182022-12-10 00:35:09kdbHáromszögekcpp11Accepted 40/40158ms5572 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<ll>vec(n);
    for (size_t i = 0; i < n; i++) cin >> vec[i];
    sort(vec.begin(), vec.end());
    while (q--)
    {
        ll b, c;
        cin >> b >> c;
        auto l = lower_bound(vec.begin(), vec.end(), abs(c - b) + 1);
        auto r = upper_bound(l, vec.end(), b + c - 1);
        cout << r - l << endl;
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1700 KiB
2Accepted0/02ms1860 KiB
3Accepted0/010ms2272 KiB
4Accepted4/44ms2284 KiB
5Accepted2/24ms2488 KiB
6Accepted1/1144ms4156 KiB
7Accepted1/1157ms4360 KiB
8Accepted2/286ms4676 KiB
9Accepted2/2101ms5000 KiB
10Accepted1/198ms4832 KiB
11Accepted1/1150ms4712 KiB
12Accepted2/298ms4748 KiB
13Accepted2/2120ms4940 KiB
14Accepted1/1104ms4888 KiB
15Accepted1/1153ms4952 KiB
16Accepted1/1150ms5204 KiB
17Accepted1/187ms5204 KiB
18Accepted1/1158ms5092 KiB
19Accepted2/2144ms5160 KiB
20Accepted2/2143ms5092 KiB
21Accepted3/3136ms5348 KiB
22Accepted5/5156ms5292 KiB
23Accepted5/5131ms5572 KiB