19162022-12-10 00:32:50kdbHáromszögekcpp11Wrong answer 6/40150ms5988 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(), c - b + 1);
        auto r = upper_bound(vec.begin(), vec.end(), b + c - 1);
        cout << r - l << endl;
    }
    return 0;
}
/*
5 6
10 3 4 6 7
5 9
5 7
6 9
6 7
2 3
2 5

*/
SubtaskSumTestVerdictTimeMemory
base6/40
1Accepted0/03ms1972 KiB
2Accepted0/02ms2036 KiB
3Wrong answer0/016ms2532 KiB
4Wrong answer0/44ms2308 KiB
5Wrong answer0/24ms2468 KiB
6Accepted1/196ms4124 KiB
7Accepted1/1150ms4324 KiB
8Accepted2/289ms4404 KiB
9Accepted2/2149ms4728 KiB
10Wrong answer0/1143ms4932 KiB
11Wrong answer0/193ms4796 KiB
12Wrong answer0/2149ms4988 KiB
13Wrong answer0/2136ms5304 KiB
14Wrong answer0/1148ms5132 KiB
15Wrong answer0/1109ms5136 KiB
16Wrong answer0/1149ms5388 KiB
17Wrong answer0/190ms5464 KiB
18Wrong answer0/1142ms5724 KiB
19Wrong answer0/2143ms5660 KiB
20Wrong answer0/289ms5988 KiB
21Wrong answer0/3150ms5928 KiB
22Wrong answer0/597ms5852 KiB
23Wrong answer0/5104ms5856 KiB