結果

問題 No.580 旅館の予約計画
ユーザー take44444take44444
提出日時 2022-02-12 16:08:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,058 bytes
コンパイル時間 2,346 ms
コンパイル使用メモリ 208,960 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 03:46:11
合計ジャッジ時間 4,154 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 3 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 3 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
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<pair<i64, i64>> &tasks, int k) {
  sort(all(tasks), [](pair<i64, i64> &a, pair<i64, i64> &b) {
    return a.second < b.second;
  });
  multiset<i64> now;
  rep (k) now.insert(0);
  int ret = 0;
  for (pair<i64, i64> &e: tasks) {
    auto itr = now.lower_bound(e.first);
    if (itr != now.begin()) {
      itr--;
      ret++;
      now.erase(itr);
      now.insert(e.second);
    }
  }
  return ret;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<i64, i64>> tasks(m);
  for (pair<i64, i64> &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;
}
0