13402022-05-21 15:43:56nkdorka1212Áruszállítás üres szakaszaicpp11Wrong answer 0/5039ms17348 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;
    int veg=0;
    vector<int>allomas(n+1,0);
    for(int i=1;i<=m;i++)
    {
        int a,b;
        cin>>a>>b;
        allomas[a]++;
        allomas[b]--;
        veg=max(veg,b);
    }
    for(int i=1;i<=veg;i++)
    {
        allomas[i]=allomas[i-1]+allomas[i];
    }
    int maxi=0;
    for(int i=1;i<=veg;i++)
    {
        int cnt=0;
        if(allomas[i]==0)
        {
            cnt++;
            i++;
            while(i<=veg && allomas[i]==0)
            {
                i++;
                cnt++;
            }
        }
        maxi=max(maxi,cnt);
    }
    /*for(int i=1;i<=veg;i++)
    {
        cout<<allomas[i]<<" ";
    }
    cout<<endl;*/
    cout<<maxi<<'\n';

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/02ms1780 KiB
2Wrong answer0/039ms10940 KiB
3Wrong answer0/21ms3256 KiB
4Wrong answer0/21ms3264 KiB
5Wrong answer0/22ms3260 KiB
6Wrong answer0/22ms3268 KiB
7Wrong answer0/21ms3268 KiB
8Wrong answer0/21ms3272 KiB
9Wrong answer0/21ms3280 KiB
10Wrong answer0/21ms3284 KiB
11Wrong answer0/22ms3608 KiB
12Wrong answer0/22ms4004 KiB
13Wrong answer0/34ms4016 KiB
14Wrong answer0/34ms4732 KiB
15Wrong answer0/34ms4836 KiB
16Wrong answer0/323ms12288 KiB
17Wrong answer0/324ms13388 KiB
18Wrong answer0/325ms14616 KiB
19Wrong answer0/36ms10052 KiB
20Wrong answer0/37ms11092 KiB
21Wrong answer0/335ms16128 KiB
22Wrong answer0/335ms17348 KiB