127822024-12-30 14:18:34KissCsongor777Áruszállítás üres szakaszaicpp17Time limit exceeded 41/50400ms4232 KiB
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,x,y,db=0;
    cin>>n>>m;
    vector<int>v(n,1);
    for(int i=1; i<=m; i++)
    {
        cin>>x>>y;
        fill(v.begin()+x-1,v.begin()+y-1,0);
    }
    /*vector<int>::iterator it;
    for(it=v.begin();it!=v.end();it++)cout<<*it<<" ";
    cout<<endl;*/
    if(v[0]==1)db++;
    if(v[n-1]==v[n-2]+1)db--;
    for(int i=0; i<n-1; i++)
        if(v[i+1]==v[i]+1)db++;
    cout<<db;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base41/50
1Accepted0/01ms320 KiB
2Accepted0/035ms4152 KiB
3Accepted2/21ms320 KiB
4Accepted2/21ms508 KiB
5Accepted2/21ms320 KiB
6Accepted2/21ms320 KiB
7Accepted2/21ms320 KiB
8Accepted2/21ms320 KiB
9Accepted2/21ms320 KiB
10Accepted2/21ms500 KiB
11Accepted2/21ms756 KiB
12Accepted2/21ms612 KiB
13Accepted3/33ms756 KiB
14Accepted3/34ms1080 KiB
15Accepted3/33ms1104 KiB
16Time limit exceeded0/3400ms4152 KiB
17Time limit exceeded0/3398ms4232 KiB
18Time limit exceeded0/3400ms4204 KiB
19Accepted3/34ms1848 KiB
20Accepted3/36ms2360 KiB
21Accepted3/328ms4152 KiB
22Accepted3/329ms4152 KiB