結果

問題 No.580 旅館の予約計画
ユーザー cielciel
提出日時 2017-10-23 01:59:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 903 bytes
コンパイル時間 715 ms
コンパイル使用メモリ 85,300 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-01 10:44:58
合計ジャッジ時間 1,577 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 3 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef pair<int,int> pii;
int main(){
	string t;
	getline(cin,t);
	int n,m;
	sscanf(t.c_str(),"%d%d",&n,&m);
	vector<pii> data(m);
	for(int i=0;i<m;i++){
		getline(cin,t);
		int i1,i2,i3,i4,i5,i6;
		sscanf(t.c_str(),"%d %d:%d %d %d:%d",&i1,&i2,&i3,&i4,&i5,&i6);
		data[i]=make_pair(i1*1440+i2*60+i3,i4*1440+i5*60+i6);
	}
	sort(data.begin(),data.end(),[](const pii &a,const pii &b){
		if(a.second!=b.second)return a.second<b.second;
		return a.first<b.first;
	});
	set<int> se;
	int r=0;
	for(int i=0;i<n;i++)se.insert(0);
	for(int i=0;i<m;i++){
		//部屋iの(出)時刻がdata[i]の入時刻より早い中で最大
		auto it=se.lower_bound(data[i].first);
		if(it!=se.begin()){
			--it;
			se.erase(it);
			se.insert(data[i].second);
			r++;
		}
	}
	printf("%d\n",r);
}
0