結果

問題 No.580 旅館の予約計画
ユーザー aaaaa
提出日時 2017-10-29 01:42:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,038 bytes
コンパイル時間 889 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-22 04:32:15
合計ジャッジ時間 2,057 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
using namespace std;

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	
	int n,m;
	cin>>n>>m;
	int ds,hs,ms,o,ho,mo;
	vector<int> s(m),e(m),end(n);
	rep(i,m){
		scanf("%d %d:%d %d %d:%d",&ds,&hs,&ms,&o,&ho,&mo);
		s[i]=ds*24*60+hs*60+ms;
		e[i]=o*24*60+ho*60+mo;
	}
	rep(i,n){
		end[i]=0;
	}
	int ans=0;
	bool a=1;
	while(a){
		a=0;
		int ii=-1,ee=INF;
		rep(i,m){
			if(e[i]<ee && s[i]>end[n-1]){
				ee=e[i];
				ii=i;
				a=1;
			}
		}
		if(a==0){
			break;
		}
		rep(i,n){
			if(end[i]<s[ii]){
				end[i]=ee;
				e[ii]=INF;
				ans++;
				break;
			}
		}
		sort(end.begin(),end.end(),greater<int>());
		
	}
	cout<<ans<<endl;




}
0