62502023-11-09 12:11:04MrChipserÁruszállítás üres szakaszaicpp11Time limit exceeded 41/50400ms17468 KiB
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int szakaszok[n-1] = {0};
    int m;
    cin >> m;
    for(int i = 0; i < m; i++)
    {
        int a,b;
        cin >> a >> b;
        for(int j = a-1; j < b-1; j++)
            szakaszok[j]+=1;
    }
    int sz = 0;
    int ures = true;
    for(int i = 0; i < n-1; i++)
    {
        if(szakaszok[i]==0 && ures)
        {
            sz++;
            ures  = false;
            //cout << i << endl;
        }
        if(szakaszok[i]!=0 && !ures)
        {
            ures = true;
        }
    }
    cout << sz;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base41/50
1Accepted0/03ms1872 KiB
2Accepted0/087ms11224 KiB
3Accepted2/23ms3648 KiB
4Accepted2/23ms3864 KiB
5Accepted2/23ms4076 KiB
6Accepted2/23ms4292 KiB
7Accepted2/23ms4416 KiB
8Accepted2/23ms4516 KiB
9Accepted2/23ms4632 KiB
10Accepted2/23ms4864 KiB
11Accepted2/23ms5308 KiB
12Accepted2/23ms5820 KiB
13Accepted3/37ms6184 KiB
14Accepted3/38ms6964 KiB
15Accepted3/37ms7212 KiB
16Time limit exceeded0/3400ms9456 KiB
17Time limit exceeded0/3342ms9444 KiB
18Time limit exceeded0/3368ms9460 KiB
19Accepted3/310ms9812 KiB
20Accepted3/312ms10796 KiB
21Accepted3/379ms16160 KiB
22Accepted3/382ms17468 KiB