結果

問題 No.580 旅館の予約計画
ユーザー aaaaaaiu
提出日時 2019-08-29 23:40:04
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 636 bytes
コンパイル時間 2,160 ms
コンパイル使用メモリ 201,876 KB
最終ジャッジ日時 2025-01-07 15:37:46
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d %d:%d %d %d:%d",&b,&c,&d,&e,&f,&g);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n,m;
    cin>>n>>m;
    pair<int,int> a[m];
    for (int i=0;i<m;i++) {
        int b,c,d,e,f,g;
        scanf("%d %d:%d %d %d:%d",&b,&c,&d,&e,&f,&g);
        a[i]={24*60*e+60*f+g,24*60*b+60*c+d};
    }
    sort(a,a+m);
    multiset<int> ms;
    for (int i=0;i<n;i++)
        ms.insert(-1);
    int ans=0;
    for (auto p:a) {
        auto it=ms.lower_bound(p.second);
        if (it!=ms.begin()) {
            it--;
            ms.erase(it);
            ms.insert(p.first);
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}
0