107872024-04-12 19:05:33TomaSajtMekk Mester munkái (50 pont)cpp17Elfogadva 50/5089ms7180 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, h;
  cin >> n >> h;

  vector<array<int, 3>> jobs;
  for (int i = 1; i <= n; i++) {
    int s, e;
    cin >> s >> e;
    jobs.push_back({s, e, i});
  }

  sort(jobs.begin(), jobs.end(), [](auto a, auto b) { return a[1] < b[1]; });

  int last_end_a = 0, last_end_b = 0;
  vector<int> done_job_ids_a, done_job_ids_b;
  for (auto [s, e, id] : jobs) {
    if (last_end_a < last_end_b) swap(last_end_a, last_end_b), swap(done_job_ids_a, done_job_ids_b);
    // let A be the person, who has been idle for the least time
    if (s > last_end_a) {
      last_end_a = e;
      done_job_ids_a.push_back(id);
    }
    else if (s > last_end_b) {
      last_end_b = e;
      done_job_ids_b.push_back(id);
    }
  }
  cout << done_job_ids_a.size() << ' ' << done_job_ids_b.size() << '\n';
  for (int id : done_job_ids_a) cout << id << ' ';
  cout << '\n';
  for (int id : done_job_ids_b) cout << id << ' ';
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/03ms1816 KiB
2Elfogadva0/08ms2628 KiB
3Elfogadva1/13ms2392 KiB
4Elfogadva1/13ms2400 KiB
5Elfogadva2/23ms2604 KiB
6Elfogadva2/23ms2716 KiB
7Elfogadva2/23ms2692 KiB
8Elfogadva2/23ms2796 KiB
9Elfogadva3/33ms2920 KiB
10Elfogadva1/13ms3148 KiB
11Elfogadva1/13ms3132 KiB
12Elfogadva2/23ms3128 KiB
13Elfogadva2/23ms3232 KiB
14Elfogadva2/23ms3124 KiB
15Elfogadva2/23ms3484 KiB
16Elfogadva3/33ms3440 KiB
17Elfogadva2/279ms6696 KiB
18Elfogadva2/279ms6820 KiB
19Elfogadva4/479ms6968 KiB
20Elfogadva4/479ms7180 KiB
21Elfogadva4/481ms7160 KiB
22Elfogadva4/481ms7160 KiB
23Elfogadva4/489ms7160 KiB