結果

問題 No.580 旅館の予約計画
ユーザー fura
提出日時 2020-05-30 10:26:20
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 2,657 ms
コンパイル使用メモリ 199,828 KB
最終ジャッジ日時 2025-01-10 19:15:03
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int input()’:
main.cpp:15:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |         int d,h,m; scanf("%d%d:%d",&d,&h,&m);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:20:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |         int k,n; scanf("%d%d",&k,&n);
      |                  ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#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-2)+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;
	vector<int> cnt(24*60*7);
	rep(i,n){
		int mx=0;
		for(int x=I[i].l;x<I[i].r;x++) mx=max(mx,cnt[x]);
		if(mx<k){
			ans++;
			for(int x=I[i].l;x<I[i].r;x++) cnt[x]++;
		}
	}
	printf("%d\n",ans);

	return 0;
}
0