85042024-01-19 15:02:44kristofMekk Mester munkái (50 pont)cpp17Wrong answer 11/50648ms7752 KiB
#include <iostream>
#include <vector>
#include <algorithm>



int keres(std::vector<int>& rendelesekKereso, int a) {
    auto it = std::find(rendelesekKereso.begin(), rendelesekKereso.end(), a);
    if (it != rendelesekKereso.end()) {
        return std::distance(rendelesekKereso.begin(), it) + 1;
    }
    return -1;
}

int main() {
    int megrendelesekSzama, napokSzama;
    std::cin >> megrendelesekSzama >> napokSzama;

    std::vector<std::pair<int, int>> rendelesek;
    std::vector<int> rendelesekKereso;

    for (int i = 0; i < megrendelesekSzama; i++) {
        int first, second;
        std::cin >> first >> second;
        rendelesek.push_back(std::make_pair(first, second));
        rendelesekKereso.push_back(first);
    }

    std::sort(rendelesek.begin(), rendelesek.end());
    std::sort(rendelesek.begin(), rendelesek.end(), [](const std::pair<int, int>& a, const std::pair<int, int>& b) {
        return a.second < b.second;
    });

    int mekkUtolso = -1;
    int fiaUtolso = 0;
    std::vector<int> mekkL;
    std::vector<int> fiaL;

    for (int i = 0; i < rendelesek.size(); i++) {
        if (fiaUtolso > mekkUtolso) {
            if (fiaUtolso < rendelesek[i].first) {
                fiaUtolso = rendelesek[i].second;
                fiaL.push_back(keres(rendelesekKereso, rendelesek[i].first));
            }
            else if (mekkUtolso < rendelesek[i].first) {
                mekkUtolso = rendelesek[i].second;
                mekkL.push_back(keres(rendelesekKereso, rendelesek[i].first));
            }
        }
        else {
            if (mekkUtolso < rendelesek[i].first) {
                mekkUtolso = rendelesek[i].second;
                mekkL.push_back(keres(rendelesekKereso, rendelesek[i].first));
            }
            else if (fiaUtolso < rendelesek[i].first) {
                fiaUtolso = rendelesek[i].second;
                fiaL.push_back(keres(rendelesekKereso, rendelesek[i].first));
            }
        }
    }

    std::cout << mekkL.size() << " " << fiaL.size() << std::endl;
    for (int i = 0; i < mekkL.size(); i++) {
        std::cout << mekkL[i] << " ";
    }
    std::cout << std::endl;
    for (int i = 0; i < fiaL.size(); i++) {
        std::cout << fiaL[i] << " ";
    }
    std::cout << std::endl;

    return 0;
}

SubtaskSumTestVerdictTimeMemory
base11/50
1Accepted0/03ms1944 KiB
2Wrong answer0/010ms2596 KiB
3Accepted1/13ms2244 KiB
4Accepted1/13ms2636 KiB
5Accepted2/23ms2952 KiB
6Accepted2/23ms2880 KiB
7Accepted2/23ms3096 KiB
8Accepted2/23ms3336 KiB
9Wrong answer0/33ms3556 KiB
10Wrong answer0/13ms3624 KiB
11Accepted1/13ms3616 KiB
12Wrong answer0/23ms3752 KiB
13Wrong answer0/23ms3840 KiB
14Wrong answer0/24ms4088 KiB
15Wrong answer0/24ms4104 KiB
16Wrong answer0/33ms4172 KiB
17Wrong answer0/2104ms7276 KiB
18Wrong answer0/2104ms7348 KiB
19Wrong answer0/4114ms7752 KiB
20Wrong answer0/4158ms7488 KiB
21Wrong answer0/4226ms7684 KiB
22Wrong answer0/4458ms7616 KiB
23Time limit exceeded0/4648ms5292 KiB