13442022-05-21 16:14:00nkdorka1212Autókódoláscpp11Wrong answer 0/508ms9508 KiB
#include <bits/stdc++.h>

using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    vector<int>allomas(n,0);
    for(int i=1;i<=m;i++)
    {
        int a,b;
        cin>>a>>b;
        allomas[a]++;
        allomas[b]--;
    }
    for(int i=1;i<=n;i++)
    {
        allomas[i]=allomas[i-1]+allomas[i];
    }
    int maxi=0;
    int k=0;
    for(int i=1;i<=n;i++)
    {
        if(allomas[i]!=0)
        {
            k=i;
            break;
        }
    }
    int mo=0;
    if(k!=1)
    {
        mo++;
    }
    for(int i=k;i<=n-1;i++)
    {
        if(allomas[i-1]!=0 && allomas[i]==0)
        {
            mo++;
        }
    }
    /*for(int x:allomas)
    {
        cout<<x<<" ";
    }*/
    cout<<mo<<'\n';

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/02ms1752 KiB
2Runtime error0/04ms2208 KiB
3Wrong answer0/21ms1864 KiB
4Wrong answer0/21ms1868 KiB
5Wrong answer0/21ms1880 KiB
6Wrong answer0/21ms1900 KiB
7Wrong answer0/21ms1908 KiB
8Wrong answer0/41ms1916 KiB
9Wrong answer0/41ms1896 KiB
10Wrong answer0/42ms2216 KiB
11Wrong answer0/42ms2220 KiB
12Wrong answer0/48ms9508 KiB
13Runtime error0/43ms2312 KiB
14Runtime error0/44ms2280 KiB
15Runtime error0/44ms2332 KiB
16Runtime error0/44ms2328 KiB
17Runtime error0/44ms2336 KiB