107872024-04-12 19:05:33TomaSajtMekk Mester munkái (50 pont)cpp17Accepted 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 << ' ';
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1816 KiB
2Accepted0/08ms2628 KiB
3Accepted1/13ms2392 KiB
4Accepted1/13ms2400 KiB
5Accepted2/23ms2604 KiB
6Accepted2/23ms2716 KiB
7Accepted2/23ms2692 KiB
8Accepted2/23ms2796 KiB
9Accepted3/33ms2920 KiB
10Accepted1/13ms3148 KiB
11Accepted1/13ms3132 KiB
12Accepted2/23ms3128 KiB
13Accepted2/23ms3232 KiB
14Accepted2/23ms3124 KiB
15Accepted2/23ms3484 KiB
16Accepted3/33ms3440 KiB
17Accepted2/279ms6696 KiB
18Accepted2/279ms6820 KiB
19Accepted4/479ms6968 KiB
20Accepted4/479ms7180 KiB
21Accepted4/481ms7160 KiB
22Accepted4/481ms7160 KiB
23Accepted4/489ms7160 KiB