結果
| 問題 |
No.580 旅館の予約計画
|
| ユーザー |
|
| 提出日時 | 2017-10-30 11:05:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,722 bytes |
| コンパイル時間 | 1,926 ms |
| コンパイル使用メモリ | 179,040 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-22 10:36:35 |
| 合計ジャッジ時間 | 3,234 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
bool cmp(pii a, pii b) {
if (a.second != b.second) {
return a.second < b.second;
} else {
return a.first > b.first;
}
}
int main(){
int N, M;
cin >> N >> M;
vi in(M), out(M);
vector<pii> reserve(M);
vi times;
rep(i, M) {
int in_d, in_h, in_m, out_d, out_h, out_m;
scanf("%d %d:%d", &in_d, &in_h, &in_m);
scanf("%d %d:%d", &out_d, &out_h, &out_m);
in[i] = in_m + 60 * (in_h + 24 * in_d);
out[i] = out_m + 60 * (out_h + 24 * out_d);
reserve[i] = mp(in[i], out[i]);
times.push_back(in[i]);
times.push_back(out[i]);
}
sort(all(times));
times.erase(unique(all(times)), times.end());
sort(all(reserve), cmp);
int T = sz(times);
auto lb = [&](int x) {
return lower_bound(all(times), x) - times.begin();
};
vi cnt(T);
int ans = 0;
each(re, reserve) {
int l = lb(re.first), r = lb(re.second);
int ma = 0;
for (int i = l; i <= r; ++i)smax(ma, cnt[i]);
if (ma < N) {
ans++;
for (int i = l; i <= r; ++i)cnt[i]++;
}
}
cout << ans << endl;
}