結果

問題 No.580 旅館の予約計画
ユーザー ikd
提出日時 2017-11-10 16:41:24
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 780 ms
コンパイル使用メモリ 108,472 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-12 22:22:37
合計ジャッジ時間 1,808 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.d(18): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`

ソースコード

diff #

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.typecons;
  
  int n, m; rd(n, m);
  auto seq=new Tuple!(int, int)[](m);
  foreach(i; 0..m){
    int d1, t11, t12, d2, t21, t22;
    scanf("%d %d:%d %d %d:%d", &d1, &t11, &t12, &d2, &t21, &t22);
    seq[i]=Tuple!(int, int)(d1*24*60+t11*60+t12, d2*24*60+t21*60+t22);
  }

  sort!"a[1]<b[1]"(seq);
  auto data=new int[](n);
  int sum=0;
  foreach(e; seq){
    int j=-1, last=-1;
    foreach(int i, t; data){
      if(t<e[0] && last<t) last=t, j=i;
    }
    if(j>=0) data[j]=e[1], 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