75372024-01-09 13:41:08rennÁruszállítás üres szakaszaicpp17Runtime error 4/5032ms64848 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n, m, a, b;
    cin >> n >> m;

    vector<queue<int>> csomagok(n+1);
    while(m--)
    {
        cin >> a >> b;
        csomagok[a].emplace(b);
    }
    int uresszam = 0;

    priority_queue<int, vector<int>, greater<int> > szallitmany;
    bool ures = true;

    for(int i = 1; i <= n; i++)
    {
        while(!szallitmany.empty())
        {
            if(szallitmany.top() != i) break;
            szallitmany.pop();
        }

        if(!ures)
        {
            if(szallitmany.empty())
            {
                uresszam++;
            }
        }

        while(!csomagok[i].empty())
        {
            szallitmany.emplace(csomagok[i].front());
            csomagok[i].pop();
        }


        ures = szallitmany.empty();
    }

    cout << uresszam << "\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/03ms1836 KiB
2Runtime error0/028ms64848 KiB
3Wrong answer0/23ms2376 KiB
4Wrong answer0/23ms2480 KiB
5Wrong answer0/23ms2876 KiB
6Wrong answer0/23ms3156 KiB
7Wrong answer0/23ms3564 KiB
8Accepted2/23ms3544 KiB
9Wrong answer0/23ms3536 KiB
10Accepted2/23ms3600 KiB
11Runtime error0/230ms63472 KiB
12Runtime error0/228ms63460 KiB
13Runtime error0/332ms63224 KiB
14Runtime error0/329ms62984 KiB
15Runtime error0/328ms62880 KiB
16Runtime error0/332ms62732 KiB
17Runtime error0/332ms62708 KiB
18Runtime error0/332ms62492 KiB
19Runtime error0/332ms62516 KiB
20Runtime error0/332ms62272 KiB
21Runtime error0/327ms62248 KiB
22Runtime error0/330ms62244 KiB