1402021-01-30 12:14:43kidesoHáromszögekcpp11Runtime error 10/40101ms83476 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

vector <int> megold, x;
vector <pair<int, int> > y;
int 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;
    }

    int 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/01ms1804 KiB
2Accepted0/01ms1852 KiB
3Accepted0/08ms3132 KiB
4Runtime error0/43ms2228 KiB
5Accepted2/22ms1924 KiB
6Runtime error0/13ms2232 KiB
7Runtime error0/135ms83476 KiB
8Accepted2/2101ms23976 KiB
9Runtime error0/24ms2232 KiB
10Accepted1/161ms4112 KiB
11Accepted1/161ms4244 KiB
12Accepted2/261ms4116 KiB
13Accepted2/265ms4332 KiB
14Runtime error0/13ms2172 KiB
15Runtime error0/13ms2232 KiB
16Runtime error0/13ms2232 KiB
17Runtime error0/13ms2228 KiB
18Runtime error0/171ms5696 KiB
19Runtime error0/274ms5720 KiB
20Runtime error0/297ms28232 KiB
21Runtime error0/34ms2228 KiB
22Runtime error0/54ms2232 KiB
23Runtime error0/53ms2164 KiB