168462025-05-14 08:02:26BencuTelefonközpontcpp17Time limit exceeded 40/100589ms1852 KiB
#include <iostream>
//#include <fstream>

using namespace std;
struct Bencu{
    int ma;
    int hely;
}a[200010];

int helyre (int elso, int utolso) {
    int i=elso, j=utolso, p=elso;
    while (i<j) {
        if (a[i].ma<a[j].ma) {
            swap(a[i],a[j]);
            if (p==i) {
                p=j;
                i++;
            }
            else {
                p=i;
                j--;
            }
        }
        else {
            if (p==i) j--;
            else i++;
        }
    }
    return p;
}
void qsort (int elso, int utolso) {
    if (elso<utolso) {
        int p=helyre (elso,utolso);
        qsort(elso,p-1);
        qsort(p+1,utolso);
    }
}

int main()
{
    int m, n, q;
    //ifstream f("be.in");
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> m >> n >> q;
    for (int i = 1; i <= n; i++) {
        int x, y;
        cin >> x >> y;
        a[x].ma++;
        a[y+1].ma--;
    }
    //int t = a[1];
    for (int i = 2; i <= m; i++) {
        a[i].ma = a[i].ma+ a[i - 1].ma;
        a[i].hely=i;
    }
    //for (int i = 1; i <= m; i++) cout << a[i].ma << " ";
    //cout << endl;
    qsort(1,m);
    for (int t = 1; t <= q; t++) {
        int x, y;
        cin >> x >> y;
        /*int ma = a[x];
        for (int i = x + 1; i <= y; i++) {
            if (a[i] > ma) ma = a[i];
        }
        cout << ma << endl;*/
        int i=1;
        while (i<=m && (a[i].hely<x || a[i].hely>y)) i++;
        cout<<a[i].ma<<endl;
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
2Accepted1ms328 KiB
subtask220/20
3Accepted2ms392 KiB
4Accepted2ms316 KiB
5Accepted1ms316 KiB
6Accepted1ms316 KiB
7Accepted1ms316 KiB
8Accepted1ms316 KiB
9Accepted1ms316 KiB
subtask320/20
10Accepted2ms392 KiB
11Accepted2ms316 KiB
12Accepted1ms316 KiB
13Accepted1ms316 KiB
14Accepted1ms316 KiB
15Accepted1ms316 KiB
16Accepted1ms316 KiB
17Accepted9ms316 KiB
18Accepted9ms460 KiB
19Accepted17ms476 KiB
20Accepted17ms476 KiB
21Accepted17ms316 KiB
22Accepted17ms576 KiB
23Accepted17ms460 KiB
subtask40/60
24Accepted2ms392 KiB
25Accepted2ms316 KiB
26Accepted1ms316 KiB
27Accepted1ms316 KiB
28Accepted1ms316 KiB
29Accepted1ms316 KiB
30Accepted1ms316 KiB
31Accepted9ms316 KiB
32Accepted9ms460 KiB
33Accepted17ms476 KiB
34Accepted17ms476 KiB
35Accepted17ms316 KiB
36Accepted17ms576 KiB
37Accepted17ms460 KiB
38Time limit exceeded588ms1844 KiB
39Time limit exceeded588ms1852 KiB
40Time limit exceeded588ms1588 KiB
41Time limit exceeded589ms1624 KiB
42Time limit exceeded579ms1772 KiB
43Time limit exceeded580ms1588 KiB
44Time limit exceeded580ms1408 KiB