62522023-11-09 12:16:25MrChipserÁruszállítás üres szakaszaicpp11Time limit exceeded 41/50400ms12120 KiB
#include <iostream>
#include <fstream>
using namespace std;
int szakaszok[1000000]= {0};
int main()
{
    ifstream fin("a.txt");
    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/03ms1688 KiB
2Accepted0/082ms9796 KiB
3Accepted2/23ms2128 KiB
4Accepted2/23ms2372 KiB
5Accepted2/23ms2424 KiB
6Accepted2/23ms2556 KiB
7Accepted2/23ms2768 KiB
8Accepted2/23ms2976 KiB
9Accepted2/23ms3156 KiB
10Accepted2/22ms3372 KiB
11Accepted2/23ms3844 KiB
12Accepted2/23ms4240 KiB
13Accepted3/37ms4504 KiB
14Accepted3/38ms5200 KiB
15Accepted3/37ms5236 KiB
16Time limit exceeded0/3400ms3728 KiB
17Time limit exceeded0/3372ms3764 KiB
18Time limit exceeded0/3400ms3648 KiB
19Accepted3/310ms7224 KiB
20Accepted3/312ms7960 KiB
21Accepted3/375ms12088 KiB
22Accepted3/379ms12120 KiB