結果

問題 No.580 旅館の予約計画
ユーザー parukiparuki
提出日時 2017-10-30 11:20:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,450 bytes
コンパイル時間 1,699 ms
コンパイル使用メモリ 173,924 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 01:20:28
合計ジャッジ時間 3,044 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
        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]);
    }
    sort(all(reserve), cmp);

    vi cnt(20000);

    int ans = 0;
    each(re, reserve) {
        int l = re.first, r = 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;
}
0