80202024-01-12 10:30:09BotiÁruszállítás üres szakaszaicpp17Time limit exceeded 2/50400ms4352 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a (m);
    vector<int> b (m);
    for (int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
    }
    int c = 0;
    int temp;
    for (int i = 0; i < m; i++)
    {
        for (int j = m -1; j > i; j--)
        {
            if (a[j] < a[j -1])
            {
                temp = a[j];
                a[j] = a[j -1];
                a[j -1] = temp;
                temp = b[j];
                b[j] = b[j -1];
                b[j -1] = temp;
            }
            else if (a[j] == a[j -1] && b[j] < b[j -1])
            {
                temp = a[j];
                a[j] = a[j -1];
                a[j -1] = temp;
                temp = b[j];
                b[j] = b[j -1];
                b[j -1] = temp;
            }
        }
    }
    int e = 0;
    for (int i = 1; i <= n; i++)
    {
        while (b[e] < i)
        {
            e++;
        }
        if (a[e] > i)
        {
            c++;
        }
    }
    /*for (int i = 0; i < m; i++)
    {
        cout << a[i] << " - " << b[i] << endl;
    }*/
    cout << c;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base2/50
1Accepted0/03ms1812 KiB
2Time limit exceeded0/0400ms1952 KiB
3Wrong answer0/23ms2224 KiB
4Accepted2/23ms2464 KiB
5Wrong answer0/23ms2712 KiB
6Wrong answer0/23ms2888 KiB
7Wrong answer0/23ms3096 KiB
8Wrong answer0/23ms3296 KiB
9Wrong answer0/23ms3496 KiB
10Wrong answer0/23ms3564 KiB
11Runtime error0/23ms3624 KiB
12Runtime error0/24ms3916 KiB
13Wrong answer0/397ms3892 KiB
14Wrong answer0/3168ms4116 KiB
15Wrong answer0/365ms4156 KiB
16Time limit exceeded0/3367ms4024 KiB
17Time limit exceeded0/3356ms4220 KiB
18Time limit exceeded0/3361ms4176 KiB
19Wrong answer0/3178ms4136 KiB
20Wrong answer0/3225ms4148 KiB
21Time limit exceeded0/3375ms4132 KiB
22Time limit exceeded0/3361ms4352 KiB