23012023-01-09 22:01:27nmarciHáromszögekcpp11Accepted 40/40209ms4236 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
const ll inf = 1e9;

int main()
{
  int n, q;
  cin >> n >> q;
  vector<int> v(n);
  for(auto& i : v){
    cin >> i;
  }
  sort(begin(v), end(v));
  while(q--){
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    auto u = lower_bound(begin(v), end(v), a + b);
    auto l = lower_bound(begin(v), end(v), b - a + 1);
    cout << u - l << endl;
  }
  return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1808 KiB
2Accepted0/02ms2008 KiB
3Accepted0/014ms2116 KiB
4Accepted4/44ms2212 KiB
5Accepted2/24ms2416 KiB
6Accepted1/1155ms3188 KiB
7Accepted1/1146ms3368 KiB
8Accepted2/2152ms3400 KiB
9Accepted2/2178ms3500 KiB
10Accepted1/1136ms3628 KiB
11Accepted1/1133ms3904 KiB
12Accepted2/2134ms3772 KiB
13Accepted2/2165ms4148 KiB
14Accepted1/1209ms4012 KiB
15Accepted1/1149ms3900 KiB
16Accepted1/1149ms4236 KiB
17Accepted1/1149ms4096 KiB
18Accepted1/1136ms4048 KiB
19Accepted2/2167ms4052 KiB
20Accepted2/2141ms4052 KiB
21Accepted3/3145ms4116 KiB
22Accepted5/5181ms4112 KiB
23Accepted5/5182ms4116 KiB