30722023-02-14 10:09:06CWMÁruszállítás üres szakaszaicpp11Wrong answer 17/5096ms8284 KiB
// nemesGyak000.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int length, q;
    cin >> length >> q;
    vector<pair<int, int>> times;
    for (size_t i = 0; i < q; i++)
    {
        int p, n;
        cin >> p >> n;
        times.push_back({p,1});
        times.push_back({n,-1 });
    }
    sort(times.begin(), times.end());
    int Index = 1;
    int SUM = 0;
    int rn = 0;
    bool Switch = true;
    if (times[0].first != 1) rn++;
    for (size_t i = 0; i < times.size(); i++)
    {
        SUM += times[i].second;
        if (times[i].first != Index) {
            Index = times[i].first;
            if (Switch && SUM == 0 && times[i].first!=length) {
                rn++;
                Switch = false;
            }
            if (SUM != 0) {
                Switch = true;
            }
        }
    }
    cout << rn;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base17/50
1Accepted0/03ms1808 KiB
2Wrong answer0/096ms6148 KiB
3Accepted2/23ms2272 KiB
4Accepted2/23ms2432 KiB
5Wrong answer0/23ms2644 KiB
6Wrong answer0/23ms2856 KiB
7Accepted2/23ms2944 KiB
8Accepted2/23ms3064 KiB
9Accepted2/23ms3296 KiB
10Accepted2/23ms3532 KiB
11Accepted2/23ms3680 KiB
12Wrong answer0/23ms3668 KiB
13Wrong answer0/38ms4320 KiB
14Wrong answer0/38ms4288 KiB
15Wrong answer0/37ms4164 KiB
16Wrong answer0/371ms7956 KiB
17Wrong answer0/372ms7964 KiB
18Wrong answer0/382ms8100 KiB
19Wrong answer0/39ms4580 KiB
20Wrong answer0/310ms4712 KiB
21Wrong answer0/386ms8284 KiB
22Accepted3/390ms8272 KiB