227432026-01-15 17:37:59Pedri26Áruszállítás üres szakaszaicpp17Time limit exceeded 11/50400ms1380 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

bool a[1000000];
int s;

int main() {

    int n, m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int b, c;
        cin>>b>>c;
        if(!a[b])
        {
            int j=b;
            while(a[j]==0 && j<=c)
            {
                a[j]=true;
                j++;
            }
        }
        if(!a[c])
        {
            int j=c;
            while(j>=b && a[j]==0)
            {
                a[j]=true;
                j--;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==0)
        {
            s++;
            while(a[i]==0 && i<n)i++;
            i--;
        }
    }
    cout<<s;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base11/50
1Time limit exceeded0/0381ms500 KiB
2Wrong answer0/076ms1332 KiB
3Time limit exceeded0/2381ms316 KiB
4Accepted2/21ms316 KiB
5Time limit exceeded0/2400ms316 KiB
6Time limit exceeded0/2377ms508 KiB
7Time limit exceeded0/2381ms500 KiB
8Time limit exceeded0/2381ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/21ms544 KiB
11Time limit exceeded0/2400ms316 KiB
12Time limit exceeded0/2384ms592 KiB
13Wrong answer0/36ms500 KiB
14Wrong answer0/38ms564 KiB
15Wrong answer0/34ms592 KiB
16Accepted3/361ms1188 KiB
17Accepted3/364ms1200 KiB
18Accepted3/371ms1300 KiB
19Wrong answer0/38ms564 KiB
20Wrong answer0/39ms896 KiB
21Wrong answer0/370ms1380 KiB
22Wrong answer0/371ms1372 KiB