結果

問題 No.759 悪くない忘年会にしような!
ユーザー te-shte-sh
提出日時 2018-12-07 17:37:29
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 1,899 bytes
コンパイル時間 2,103 ms
コンパイル使用メモリ 105,824 KB
実行使用メモリ 7,512 KB
最終ジャッジ日時 2023-09-03 21:25:04
合計ジャッジ時間 6,722 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,384 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,384 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 8 ms
4,376 KB
testcase_34 AC 3 ms
4,376 KB
testcase_35 AC 5 ms
4,800 KB
testcase_36 AC 8 ms
4,376 KB
testcase_37 AC 3 ms
4,380 KB
testcase_38 AC 9 ms
4,380 KB
testcase_39 AC 3 ms
4,380 KB
testcase_40 AC 6 ms
4,376 KB
testcase_41 AC 7 ms
4,380 KB
testcase_42 AC 9 ms
4,376 KB
testcase_43 AC 9 ms
4,380 KB
testcase_44 AC 80 ms
6,960 KB
testcase_45 AC 80 ms
6,604 KB
testcase_46 AC 81 ms
6,672 KB
testcase_47 AC 81 ms
6,660 KB
testcase_48 AC 80 ms
6,696 KB
testcase_49 AC 10 ms
4,376 KB
testcase_50 AC 10 ms
4,380 KB
testcase_51 AC 10 ms
4,388 KB
testcase_52 AC 10 ms
4,380 KB
testcase_53 AC 79 ms
6,696 KB
testcase_54 AC 81 ms
6,640 KB
testcase_55 AC 80 ms
6,624 KB
testcase_56 AC 81 ms
6,964 KB
testcase_57 AC 80 ms
6,632 KB
testcase_58 AC 80 ms
6,656 KB
testcase_59 AC 80 ms
6,668 KB
testcase_60 AC 80 ms
6,648 KB
testcase_61 AC 80 ms
6,656 KB
testcase_62 AC 80 ms
7,512 KB
testcase_63 AC 95 ms
6,704 KB
testcase_64 AC 97 ms
6,608 KB
testcase_65 AC 71 ms
6,664 KB
testcase_66 AC 95 ms
6,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n; readV(n);
  int[] p, t, r; readC(n, p, t, r);

  struct S { int p, t, r, i; }
  auto s = new S[](n);
  foreach (i; 0..n) s[i] = S(p[i]+1, t[i]+1, r[i]+1, i);

  s.multiSort!("a.p>b.p", "a.t>b.t", "a.r>b.r");

  auto st = new SegmentTree!(int, max)(10^^4+2), b = new bool[](n);
  b[] = true;

  foreach (si; s) {
    if (st[si.t..$] >= si.r)
      b[si.i] = false;

    st[si.t] = max(st[si.t], si.r);
  }

  foreach (i; 0..n)
    if (b[i]) writeln(i+1);
}

class SegmentTree(T, alias pred = "a + b")
{
  import core.bitop, std.functional;
  alias predFun = binaryFun!pred;

  const size_t n, an;
  T[] buf;
  T unit;

  this(size_t n, T unit = T.init)
  {
    this.n = n;
    this.unit = unit;
    an = n == 1 ? 1 : (1 << ((n-1).bsr + 1));
    buf = new T[](an*2);
    if (T.init != unit) buf[] = unit;
  }

  this(T[] init, T unit = T.init)
  {
    this(init.length, unit);
    buf[an..an+n][] = init[];
    foreach_reverse (i; 1..an)
      buf[i] = predFun(buf[i*2], buf[i*2+1]);
  }

  void opIndexAssign(T val, size_t i)
  {
    buf[i += an] = val;
    while (i /= 2)
      buf[i] = predFun(buf[i*2], buf[i*2+1]);
  }

  pure T opSlice(size_t l, size_t r)
  {
    l += an; r += an;
    T r1 = unit, r2 = unit;
    while (l != r) {
      if (l % 2) r1 = predFun(r1, buf[l++]);
      if (r % 2) r2 = predFun(buf[--r], r2);
      l /= 2; r /= 2;
    }
    return predFun(r1, r2);
  }

  pure T opIndex(size_t i) { return buf[i+an]; }
  pure size_t opDollar() { return n; }
}
0