結果
問題 | No.580 旅館の予約計画 |
ユーザー |
![]() |
提出日時 | 2017-10-10 17:26:03 |
言語 | C++11 (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,101 bytes |
コンパイル時間 | 1,362 ms |
コンパイル使用メモリ | 167,528 KB |
実行使用メモリ | 17,104 KB |
最終ジャッジ日時 | 2024-11-21 13:37:53 |
合計ジャッジ時間 | 101,516 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 TLE * 33 |
コンパイルメッセージ
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); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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;}