1462021-02-01 15:42:47kidesoHáromszögekcpp11Wrong answer 11/40115ms28012 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

#define ll long long
using namespace std;

//ifstream cin("harom.in");
//ofstream cout("harom.out");

vector <ll> megold, x;
vector <pair<ll, ll> > y;
ll N, Q, a, b, i, j;

int main()
{
    cin >> N >> Q;
    x.resize(N);

    for (i = 0; i < N; ++i)
        cin >> x[i];

    sort(x.begin(), x.end());

    ll k = x.back();
    x.push_back(k + 1);

    y.push_back({ 0,0 });
    for (i = 1; i <= Q; ++i)
    {
        cin >> a >> b;
        y.push_back({ abs(b - a) + 1, min(a + b - 1,k) });
    }

    megold.resize(Q + 1, 0);

    vector <ll>::iterator it1, it2;
    ll ind1, ind2;

    for (i = 1; i <= Q; ++i)
    {
        it1 = lower_bound(x.begin(), x.end(), y[i].first);
        it2 = lower_bound(x.begin(), x.end(), y[i].second);
        ind1 = it1 - x.begin();
        ind2 = it2 - x.begin();
        megold[i] = ind2 - ind1 + 1;
    }

    for (i = 1; i <= Q; ++i)
        cout << megold[i] << '\n';
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base11/40
1Accepted0/01ms1800 KiB
2Accepted0/01ms1832 KiB
3Accepted0/09ms2400 KiB
4Wrong answer0/43ms2056 KiB
5Wrong answer0/22ms2088 KiB
6Wrong answer0/1104ms8964 KiB
7Accepted1/198ms10584 KiB
8Accepted2/292ms12340 KiB
9Accepted2/296ms14116 KiB
10Accepted1/183ms15264 KiB
11Accepted1/182ms15268 KiB
12Accepted2/279ms15264 KiB
13Accepted2/292ms15168 KiB
14Wrong answer0/1115ms17188 KiB
15Wrong answer0/197ms18848 KiB
16Wrong answer0/193ms20432 KiB
17Wrong answer0/193ms22304 KiB
18Wrong answer0/186ms22284 KiB
19Wrong answer0/287ms22256 KiB
20Wrong answer0/287ms22332 KiB
21Wrong answer0/396ms24084 KiB
22Wrong answer0/5114ms26096 KiB
23Wrong answer0/5114ms28012 KiB