結果

問題 No.580 旅館の予約計画
ユーザー fura
提出日時 2020-05-30 10:08:39
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 743 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,916 ms
コンパイル使用メモリ 224,992 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2026-06-10 10:19:49
合計ジャッジ時間 2,943 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

template<class T> struct interval{
	T l,r;
	interval(){}
	interval(const T& l,const T& r):l(l),r(r){}
	bool operator<(const interval& I)const{ return make_tuple(r,l)<make_tuple(I.r,I.l); }
};

int input(){
	int d,h,m; scanf("%d%d:%d",&d,&h,&m);
	return 24*60*d+60*h+m;
}

int main(){
	int k,n; scanf("%d%d",&k,&n);
	vector<interval<int>> I(n);
	rep(i,n){
		I[i].l=input();
		I[i].r=input()+1;
	}

	sort(I.begin(),I.end());

	int ans=0,cnt=0;
	priority_queue<int,vector<int>,greater<int>> Q;
	rep(i,n){
		while(!Q.empty() && Q.top()<=I[i].l) Q.pop(), cnt--;
		if(cnt<k){
			Q.emplace(I[i].r);
			ans++;
			cnt++;
		}
	}
	printf("%d\n",ans);

	return 0;
}
0