結果

問題 No.545 ママの大事な二人の子供
ユーザー te-shte-sh
提出日時 2017-07-14 23:21:54
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,793 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 113,512 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-03 15:15:42
合計ジャッジ時間 1,958 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
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 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.d(16): Warning: statement is not reachable
Main.d(17): Warning: statement is not reachable
Main.d(17): Warning: statement is not reachable
Main.d(18): Warning: statement is not reachable
Main.d(24): Warning: statement is not reachable
Main.d(29): Warning: statement is not reachable
Main.d(29): Warning: statement is not reachable
Main.d(30): Warning: statement is not reachable
Main.d(30): Warning: statement is not reachable
Main.d(32): Warning: statement is not reachable
Main.d(41): Warning: statement is not reachable
Main.d(50): Warning: statement is not reachable
Main.d(51): Warning: statement is not reachable
Main.d(53): Warning: statement is not reachable
Main.d(54): Warning: statement is not reachable
Main.d(66): Warning: statement is not reachable

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container; // SList, DList, BinaryHeap
import std.typecons;  // Tuple, Nullable, BigFlags
import std.math;      // math functions
import std.numeric;   // gcd, fft
import std.bigint;    // BigInt
import std.random;    // random
import std.bitmanip;  // BitArray
import core.bitop;    // bit operation
import std.regex;     // RegEx
import std.uni;       // unicode

void main()
{
  return;
  auto n = readln.chomp.to!size_t;
  auto a = new long[](n), b = new long[](n);
  foreach (i; 0..n) {
    auto rd = readln.split.to!(long[]);
    a[i] = rd[0];
    b[i] = rd[1];
  }

  if (n == 1) {
    writeln(min(a[0], b[0]));
    return;
  }

  auto n1 = n/2, n2 = n- n1;
  long[] s1, s2;

  foreach (i; 0..1 << n1) {
    auto sa = 0L, sb = 0L;
    foreach (j; 0..n1) {
      if (i.bitTest(j)) sa += a[j];
      else              sb += b[j];
    }
    s1 ~= sa - sb;
  }

  foreach (i; 0..1 << n2) {
    auto sa = 0L, sb = 0L;
    foreach (j; 0..n2) {
      if (i.bitTest(j)) sa += a[n1+j];
      else              sb += b[n1+j];
    }
    s2 ~= sa - sb;
  }

  s2.sort();
  auto s2s = s2.assumeSorted;

  auto r = long.max;
  foreach (s1i; s1) {
    auto t0 = s2s.equalRange(-s1i);
    if (!t0.empty) {
      writeln(0);
      return;
    }
    auto t1 = s2s.lowerBound(-s1i);
    if (!t1.empty) r = min(r, (s1i + t1.back).abs);
    auto t2 = s2s.upperBound(-s1i);
    if (!t2.empty) r = min(r, (s1i + t2.front).abs);
  }

  writeln(r);
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }
}
0