65552023-12-09 14:40:42horvathabelHáromszögekcpp17Accepted 40/40212ms5384 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n,k;
	cin>>n>>k;
	vector<int> l;
	for  (int i=0; i<n;i++){
		int x;
		cin>>x;
		l.push_back(x);
	}
	sort(l.begin(),l.end());
	for (int i=0; i<k;i++){
		int a,b;
		cin>>a>>b;
		if (a>b) swap(a,b);
		cout<<upper_bound(l.begin(),l.end(),b+a-1)-lower_bound(l.begin(),l.end(),b-a+1)<<endl; 
	}
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1812 KiB
2Accepted0/03ms2056 KiB
3Accepted0/019ms2532 KiB
4Accepted4/44ms2520 KiB
5Accepted2/24ms2648 KiB
6Accepted1/1156ms3844 KiB
7Accepted1/1181ms3976 KiB
8Accepted2/2182ms4068 KiB
9Accepted2/2181ms4404 KiB
10Accepted1/1146ms4368 KiB
11Accepted1/1134ms4504 KiB
12Accepted2/2135ms4580 KiB
13Accepted2/2136ms4716 KiB
14Accepted1/1164ms4924 KiB
15Accepted1/1150ms5156 KiB
16Accepted1/1180ms5140 KiB
17Accepted1/1170ms5228 KiB
18Accepted1/1165ms5220 KiB
19Accepted2/2138ms5384 KiB
20Accepted2/2164ms5232 KiB
21Accepted3/3182ms5232 KiB
22Accepted5/5167ms5216 KiB
23Accepted5/5212ms5216 KiB