75262024-01-09 13:27:14rennÁruszállítás üres szakaszaicpp17Runtime error 4/5035ms64856 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    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 = false;

    for(int i = 1; i <= n; i++)
    {
        if(ures)
        {
            if(!szallitmany.empty())
            {
                uresszam++;
            }
        }

        ures = szallitmany.empty();

        if(!szallitmany.empty())
            while(szallitmany.top() == i)
            {
                szallitmany.pop();
                if(szallitmany.empty())
                    break;
            }

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

    cout << uresszam << "\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/03ms1820 KiB
2Runtime error0/035ms64856 KiB
3Wrong answer0/23ms2128 KiB
4Wrong answer0/23ms2332 KiB
5Wrong answer0/23ms2756 KiB
6Wrong answer0/23ms3032 KiB
7Wrong answer0/23ms3436 KiB
8Wrong answer0/23ms3108 KiB
9Accepted2/23ms3308 KiB
10Accepted2/23ms3372 KiB
11Runtime error0/234ms63896 KiB
12Runtime error0/234ms63652 KiB
13Runtime error0/334ms63636 KiB
14Runtime error0/329ms63396 KiB
15Runtime error0/335ms63360 KiB
16Runtime error0/329ms63364 KiB
17Runtime error0/334ms63356 KiB
18Runtime error0/329ms63348 KiB
19Runtime error0/329ms63328 KiB
20Runtime error0/332ms63296 KiB
21Runtime error0/328ms63056 KiB
22Runtime error0/332ms63052 KiB