78782024-01-11 16:57:54mmatedHáromszögekcpp17Accepted 40/4059ms8096 KiB
#include <bits/stdc++.h>
using namespace std;
#define f(i,k,n) for(int i=k; i<n; i++)
#define ll long long
const int inf = INT_MAX;

void solve()
{
    int n,q;
    cin>>n>>q;
    vector<int> a(n);
    f(i,0,n)    cin>>a[i];
    sort(a.begin(),a.end());
    int x,y;
    f(i,0,q)
    {
        cin>>x>>y;
        cout<<lower_bound(a.begin(),a.end(),x+y)-lower_bound(a.begin(),a.end(),abs(x-y)+1)<<"\n";
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--)  solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1828 KiB
2Accepted0/03ms2056 KiB
3Accepted0/07ms2576 KiB
4Accepted4/43ms2732 KiB
5Accepted2/23ms2720 KiB
6Accepted1/150ms5656 KiB
7Accepted1/145ms7036 KiB
8Accepted2/245ms7040 KiB
9Accepted2/245ms7296 KiB
10Accepted1/150ms7296 KiB
11Accepted1/148ms7516 KiB
12Accepted2/250ms7720 KiB
13Accepted2/250ms7660 KiB
14Accepted1/157ms7660 KiB
15Accepted1/152ms7660 KiB
16Accepted1/152ms7656 KiB
17Accepted1/146ms7864 KiB
18Accepted1/143ms7816 KiB
19Accepted2/243ms7816 KiB
20Accepted2/245ms7820 KiB
21Accepted3/346ms7876 KiB
22Accepted5/557ms8096 KiB
23Accepted5/559ms8084 KiB