80082024-01-12 10:12:10BotiÁruszállítás üres szakaszaicpp17Time limit exceeded 8/50400ms4288 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;
    bool d = true;
    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)
        {
            if (d)
            {
                d = false;
                c++;
            }
        }
        else
        {
            d = true;
        }
    }
    cout << c;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/03ms1812 KiB
2Time limit exceeded0/0400ms2044 KiB
3Accepted2/23ms2228 KiB
4Accepted2/23ms2472 KiB
5Wrong answer0/23ms2668 KiB
6Wrong answer0/23ms2916 KiB
7Wrong answer0/22ms2968 KiB
8Wrong answer0/23ms2940 KiB
9Accepted2/23ms2936 KiB
10Accepted2/23ms3188 KiB
11Runtime error0/23ms3120 KiB
12Runtime error0/24ms3380 KiB
13Wrong answer0/397ms3560 KiB
14Wrong answer0/3167ms3704 KiB
15Wrong answer0/365ms3936 KiB
16Time limit exceeded0/3382ms3652 KiB
17Time limit exceeded0/3361ms3840 KiB
18Time limit exceeded0/3354ms4012 KiB
19Wrong answer0/3178ms4288 KiB
20Wrong answer0/3225ms4172 KiB
21Time limit exceeded0/3307ms3960 KiB
22Time limit exceeded0/3358ms4032 KiB