198662025-12-27 14:15:11szabelrMekk Mester munkái (50 pont)cpp17Elfogadva 50/50112ms6444 KiB
// Mekk Mester munkái.cpp : Tis file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>
int main()
{
    int n, h,x,y;
    cin >> n >> h;
    vector<vector<int>> munkak(n);
    vector<int> res1;
    vector<int> res2;
    for (int i = 0; i < n; i++)
    {
        cin >> x>>y;
        munkak[i].push_back(x);
        munkak[i].push_back(y);
        munkak[i].push_back(i + 1);
    }
    sort(munkak.begin(), munkak.end(), [](const auto& a, const auto& b)
        {
            return a[1] < b[1];
        });
    int db1 = 1, db2 = 0;
    int end1 = munkak[0][1];
    res1.push_back(munkak[0][2]);
    int end2 = -1;
    for (int i = 1; i < n; i++)
    {
        bool k1 = munkak[i][0] > end1;
        bool k2 = munkak[i][0] > end2;
        if (k1 && (!k2 || end1 > end2))
        {
            db1++;
            end1 = munkak[i][1];
            res1.push_back(munkak[i][2]);
        }
        else if (k2) 
        {
            db2++;
            end2 = munkak[i][1];
            res2.push_back(munkak[i][2]);
        }
    }
    cout << db1 << " " << db2 << endl;
    for (auto x : res1) {
        cout << x << " ";
    }
    cout << endl;
    for (auto x : res2) {
        cout << x << " ";
    }
}

// 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
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/01ms316 KiB
2Elfogadva0/08ms820 KiB
3Elfogadva1/11ms316 KiB
4Elfogadva1/11ms316 KiB
5Elfogadva2/21ms316 KiB
6Elfogadva2/21ms316 KiB
7Elfogadva2/21ms508 KiB
8Elfogadva2/21ms344 KiB
9Elfogadva3/31ms316 KiB
10Elfogadva1/12ms316 KiB
11Elfogadva1/12ms316 KiB
12Elfogadva2/22ms316 KiB
13Elfogadva2/22ms316 KiB
14Elfogadva2/22ms316 KiB
15Elfogadva2/22ms500 KiB
16Elfogadva3/32ms332 KiB
17Elfogadva2/298ms5724 KiB
18Elfogadva2/2101ms5884 KiB
19Elfogadva4/4101ms5844 KiB
20Elfogadva4/498ms5712 KiB
21Elfogadva4/4100ms5956 KiB
22Elfogadva4/4104ms5940 KiB
23Elfogadva4/4112ms6444 KiB