結果

問題 No.580 旅館の予約計画
ユーザー ikdikd
提出日時 2017-11-09 19:51:36
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 850 bytes
コンパイル時間 1,037 ms
コンパイル使用メモリ 108,188 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-03 16:43:05
合計ジャッジ時間 2,588 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.typecons, std.container;
  
  int n, m; rd(n, m);
  auto seq=new Tuple!(int, int)[](m);
  foreach(i; 0..m){
    int d1, d2;
    string t1, t2;
    rd(d1, t1, d2, t2);
    auto st=d1*24*60+to!(int)(t1[0..2])*60+to!(int)(t1[3..$]);
    auto ed=d2*24*60+to!(int)(t2[0..2])*60+to!(int)(t2[3..$]);
    seq[i]=Tuple!(int, int)(st, ed);
  }
  
  sort!"a[1]<b[1]"(seq);

  alias P=Tuple!(int, int);
  auto Q=new BinaryHeap!(Array!P, "a[0]>a[1]");
  auto sum=0;
  foreach(e; seq){
    while(Q.length>0 && Q.front[1]<e[0]) Q.removeFront;
    if(Q.length<n)Q.insert(P(e)), sum++;
  }
  writeln(sum);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
0