結果
問題 | No.580 旅館の予約計画 |
ユーザー |
![]() |
提出日時 | 2017-10-10 17:24:53 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 900 bytes |
コンパイル時間 | 1,325 ms |
コンパイル使用メモリ | 163,544 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-21 13:36:11 |
合計ジャッジ時間 | 2,206 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
コンパイルメッセージ
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;}}priority_queue<Pi, vector<Pi>, greater<Pi>> que;for(int i = 0; i < m; i++) {que.emplace(t[i][1], t[i][0]);}int room[101] = {};int ans = 0;auto print = [&](int ts) {printf("%d %d:%d\n", ts/(24*60), ts%(24*60)/60, ts%(24*60)%60);};while(!que.empty()) {Pi p = que.top(); que.pop();int idx = -1;for(int i = 0; i < n; i++) {if(room[i] >= p.second) continue;if(idx == -1 || room[idx] < room[i]) idx = i;}if(~idx) {ans++;room[idx] = p.first;//print(p.first);}}printf("%d\n", ans);return 0;}