61142023-11-01 18:13:15GhostZsonglőrködéscpp17Wrong answer 0/1001.582s6104 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n, i, out = 0;
    cin >> n;

    vector<pair<int, int>> foglalasok(n);
    for (i = 0; i < n; i++) {
        cin >> foglalasok[i].first >> foglalasok[i].second;
    }

    sort(foglalasok.begin(), foglalasok.end(), [](pair<int, int> a, pair<int, int> b) {
        if (a.second == b.second) {
            return a.first < b.first;
        }
        else {
            return a.second < b.second;
        }
    });
   
    while (out != n && foglalasok.size() > 0) {
        vector<int> erase;
        erase.push_back(0);
        int last = foglalasok[0].second;
        i = 1;
        while (i < foglalasok.size()) {
            if (foglalasok[i].first >= last) {
                last = foglalasok[i].second;
                erase.push_back(i-erase.size());
            }
            i++;
        }
        for (int j = 0; j < erase.size(); j++) {
            foglalasok.erase(foglalasok.begin()+erase[j]);
        }
        erase.clear();
        out++;
    }
    cout << out;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1816 KiB
2Accepted3ms2004 KiB
subtask20/20
3Wrong answer6ms2232 KiB
4Wrong answer1.376s2996 KiB
5Time limit exceeded1.56s2920 KiB
6Time limit exceeded1.582s3528 KiB
7Time limit exceeded1.542s3864 KiB
8Time limit exceeded1.577s3856 KiB
9Time limit exceeded1.57s3968 KiB
10Time limit exceeded1.565s4048 KiB
11Time limit exceeded1.562s4300 KiB
subtask30/35
12Wrong answer3ms3504 KiB
13Accepted3ms3756 KiB
14Wrong answer3ms4000 KiB
15Accepted3ms4088 KiB
16Wrong answer4ms4168 KiB
17Wrong answer4ms4448 KiB
18Wrong answer4ms4612 KiB
19Wrong answer4ms4680 KiB
20Wrong answer4ms4756 KiB
subtask40/45
21Wrong answer6ms4852 KiB
22Time limit exceeded1.557s4568 KiB
23Time limit exceeded1.577s5372 KiB
24Time limit exceeded1.565s5744 KiB
25Time limit exceeded1.574s6004 KiB
26Time limit exceeded1.565s5944 KiB
27Time limit exceeded1.557s6068 KiB
28Time limit exceeded1.57s6028 KiB
29Time limit exceeded1.565s6104 KiB