結果

問題 No.580 旅館の予約計画
ユーザー ukuku09ukuku09
提出日時 2017-10-10 17:26:03
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,101 bytes
コンパイル時間 1,515 ms
コンパイル使用メモリ 167,640 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-05-01 10:09:14
合計ジャッジ時間 4,927 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |   scanf("%d %d", &n, &m);
      |   ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:14:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |       scanf("%d %d:%d", &d, &h, &m);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using Pi = pair<int, int>;

int main() {
  int n, m;
  int t[1001][2];
  scanf("%d %d", &n, &m);
  for(int i = 0; i < m; i++) {
    for(int j = 0; j < 2; j++) {
      int d, h, m;
      scanf("%d %d:%d", &d, &h, &m);
      t[i][j] = d*24*60+h*60+m;
    }
  }
  vector<Pi> vec;
  for(int i = 0; i < m; i++) {
    vec.emplace_back(t[i][0], t[i][1]);
  }
  sort(vec.begin(), vec.end());
  int room[101] = {};
  vector<int> who;
  int ans = 0;
  auto print = [&](int ts) {
    printf("%d %d:%d\n", ts/(24*60), ts%(24*60)/60, ts%(24*60)%60);
  };
  function<void(int,int)> dfs = [&](int idx, int cnt) {
    if(idx == m) {
      ans = max(ans, cnt);
      /*
      if(cnt == 11) {
	for(int s : who) {
	  print(s);
	}
	exit(0);
      }
      */
      return;
    }
    dfs(idx+1, cnt);
    for(int i = 0; i < n; i++) {
      if(room[i] < vec[idx].first) {
	int tmp = room[i];
	room[i] = vec[idx].second;
	who.push_back(vec[idx].second);
	dfs(idx+1, cnt+1);
	who.pop_back();
	room[i] = tmp;
      }
    }
  };
  dfs(0, 0);
  printf("%d\n", ans);

  return 0;
}
0