結果
| 問題 |
No.580 旅館の予約計画
|
| ユーザー |
|
| 提出日時 | 2017-10-30 11:23:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 1,452 bytes |
| コンパイル時間 | 1,947 ms |
| コンパイル使用メモリ | 175,896 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-22 10:37:18 |
| 合計ジャッジ時間 | 2,750 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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);
rep(i, M) {
int in_d, in_h, in_m, out_d, out_h, out_m;
char hoge;
cin >> in_d >> in_h >> hoge >> in_m;
cin >> out_d >> out_h >> hoge >> 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]);
}
sort(all(reserve), cmp);
vi cnt(20000);
int ans = 0;
each(re, reserve) {
int l, r, ma = 0;
tie(l, r) = re;
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;
}