1412021-01-30 12:17:21kidesoHáromszögekcpp11Runtime error 10/40119ms54648 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;
    for (i = 1; i <= N; ++i)
    {
        cin >> a;
        if (x.size() < a + 1) x.resize(a + 1);
        x[a] = 1;
    }

    ll k = x.size() - 1;
    for (i = 1; i <= k; ++i)
        x[i] += x[i - 1];

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

    megold.resize(Q + 1, 0);

    for (i = 1; i <= Q; ++i)
    {
        megold[i] = x[min(y[i].second, k)] - x[y[i].first];
    }


    for (i = 1; i <= Q; ++i)
        cout << megold[i] << '\n';
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base10/40
1Accepted0/01ms1800 KiB
2Accepted0/01ms1828 KiB
3Accepted0/08ms4296 KiB
4Runtime error0/44ms2156 KiB
5Accepted2/22ms1968 KiB
6Runtime error0/13ms2164 KiB
7Runtime error0/13ms2156 KiB
8Accepted2/2119ms46412 KiB
9Runtime error0/23ms2156 KiB
10Accepted1/168ms7016 KiB
11Accepted1/167ms7056 KiB
12Accepted2/268ms6416 KiB
13Accepted2/270ms6816 KiB
14Runtime error0/13ms2156 KiB
15Runtime error0/13ms2164 KiB
16Runtime error0/14ms2168 KiB
17Runtime error0/13ms2220 KiB
18Runtime error0/179ms9460 KiB
19Runtime error0/282ms9428 KiB
20Runtime error0/2118ms54648 KiB
21Runtime error0/34ms2224 KiB
22Runtime error0/54ms2220 KiB
23Runtime error0/53ms2228 KiB