13412022-05-21 15:52:53nkdorka1212Áruszállítás üres szakaszaicpp11Wrong answer 14/5034ms17308 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+1,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;i++)
    {
        if(allomas[i-1]!=0 && allomas[i]==0)
        {
            mo++;
        }
    }
    cout<<mo<<'\n';

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base14/50
1Accepted0/02ms1760 KiB
2Wrong answer0/034ms10816 KiB
3Accepted2/21ms3220 KiB
4Wrong answer0/21ms3228 KiB
5Accepted2/21ms3228 KiB
6Accepted2/21ms3232 KiB
7Accepted2/21ms3236 KiB
8Accepted2/21ms3240 KiB
9Wrong answer0/21ms3248 KiB
10Wrong answer0/21ms3244 KiB
11Accepted2/21ms3572 KiB
12Accepted2/22ms3972 KiB
13Wrong answer0/33ms3980 KiB
14Wrong answer0/34ms4696 KiB
15Wrong answer0/34ms4796 KiB
16Wrong answer0/324ms12256 KiB
17Wrong answer0/325ms13320 KiB
18Wrong answer0/326ms14580 KiB
19Wrong answer0/36ms10016 KiB
20Wrong answer0/37ms11052 KiB
21Wrong answer0/330ms16092 KiB
22Wrong answer0/334ms17308 KiB