62512023-11-09 12:13:44MrChipserÁruszállítás üres szakaszaicpp11Time limit exceeded 41/50374ms12060 KiB
#include <iostream>

using namespace std;
int szakaszok[1000000]= {0};
int main()
{
    int n;
    cin >> n;
    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/03ms2152 KiB
2Accepted0/086ms10064 KiB
3Accepted2/23ms2324 KiB
4Accepted2/23ms2500 KiB
5Accepted2/23ms2732 KiB
6Accepted2/23ms2952 KiB
7Accepted2/23ms3016 KiB
8Accepted2/22ms3020 KiB
9Accepted2/23ms3144 KiB
10Accepted2/23ms3216 KiB
11Accepted2/23ms3620 KiB
12Accepted2/23ms4176 KiB
13Accepted3/37ms4020 KiB
14Accepted3/38ms5020 KiB
15Accepted3/37ms4976 KiB
16Time limit exceeded0/3349ms3392 KiB
17Time limit exceeded0/3374ms3372 KiB
18Time limit exceeded0/3342ms3896 KiB
19Accepted3/310ms7456 KiB
20Accepted3/312ms8392 KiB
21Accepted3/383ms12052 KiB
22Accepted3/381ms12060 KiB