#include using namespace std; #define i64 int64_t #define endl "\n" #define all(a) a.begin(),a.end() #define rep(n) for(int i = 0; i < (n); i++) int overlapping_interval_scheduling_problem(vector> &tasks, int k) { sort(all(tasks), [](pair &a, pair &b) { return a.second < b.second; }); multiset now; rep (k) now.insert(0); int ret = 0; for (pair &e: tasks) { auto itr = now.lower_bound(e.first); if (itr != now.begin()) { itr--; ret++; now.erase(itr); now.insert(e.second); } } return ret; } void Main() { int n, m; cin >> n >> m; vector> tasks(m); for (pair &e: tasks) { i64 ld, rd; string lt_s, rt_s; cin >> ld >> lt_s >> rd >> rt_s; i64 lt = stoi(lt_s.substr(0, 2)) * 60 + stoi(lt_s.substr(3, 2)), rt = stoi(rt_s.substr(0, 2)) * 60 + stoi(rt_s.substr(3, 2)); e = {ld * 1440 + lt, rd * 1440 + rt}; } cout << overlapping_interval_scheduling_problem(tasks, n) << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(10) << fixed; Main(); }