結果

問題 No.647 明太子
ユーザー arukukaarukuka
提出日時 2018-02-09 23:02:18
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 47 ms / 4,500 ms
コード長 903 bytes
コンパイル時間 1,056 ms
コンパイル使用メモリ 91,712 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 18:39:59
合計ジャッジ時間 2,786 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,384 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 5 ms
4,384 KB
testcase_14 AC 37 ms
4,380 KB
testcase_15 AC 7 ms
4,384 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 45 ms
4,380 KB
testcase_18 AC 47 ms
4,380 KB
testcase_19 AC 11 ms
4,384 KB
testcase_20 AC 10 ms
4,380 KB
testcase_21 AC 5 ms
4,380 KB
testcase_22 AC 27 ms
4,380 KB
testcase_23 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;

void main()
{
  int n = readln.chomp.to!int;
  int[] a, b;
  foreach (i; 0..n) {
    auto v = readln.chomp.split.map!(to!int);
    a ~= v.front;
    b ~= v.back;
  }
  int m = readln.chomp.to!int;
  int[] x, y;
  foreach (i; 0..m) {
    auto v = readln.chomp.split.map!(to!int);
    x ~= v.front;
    y ~= v.back;
  }
  alias Node = Tuple!(int, "count", int, "index");
  Node[] arr;
  foreach (i; 0..m) {
    int cnt = 0;
    foreach (j; 0..n) {
      if (x[i] > a[j]) {
        continue;
      }
      if (y[i] < b[j]) {
        continue;
      }
      ++cnt;
    }
    arr ~= Node(cnt, i + 1);
  }
  auto val = arr.reduce!max;
  if (val.count) {
    foreach (w; arr.filter!(a => a.count == val.count)) {
      writeln = w.index;
    }
  } else {
    0.writeln;
  }
}
0