1392021-01-30 12:12:39kidesoHáromszögekcpp11Runtime error 2/40105ms83588 KiB
#include <iostream>
#include <vector>
#include <algorithm>

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({ 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
base2/40
1Accepted0/02ms1808 KiB
2Accepted0/02ms1836 KiB
3Runtime error0/013ms3136 KiB
4Runtime error0/44ms2372 KiB
5Wrong answer0/22ms2080 KiB
6Runtime error0/13ms2396 KiB
7Runtime error0/135ms83588 KiB
8Accepted2/2105ms24104 KiB
9Runtime error0/23ms4160 KiB
10Wrong answer0/171ms7132 KiB
11Wrong answer0/165ms8372 KiB
12Wrong answer0/264ms9340 KiB
13Wrong answer0/268ms10780 KiB
14Runtime error0/13ms8644 KiB
15Runtime error0/14ms8656 KiB
16Runtime error0/13ms8676 KiB
17Runtime error0/14ms8696 KiB
18Runtime error0/193ms13692 KiB
19Runtime error0/272ms15316 KiB
20Runtime error0/297ms37768 KiB
21Runtime error0/33ms13476 KiB
22Runtime error0/53ms13488 KiB
23Runtime error0/53ms13508 KiB