結果

問題 No.180 美しいWhitespace (2)
ユーザー ikdikd
提出日時 2017-11-14 21:39:49
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 838 bytes
コンパイル時間 907 ms
コンパイル使用メモリ 89,980 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-03 16:54:44
合計ジャッジ時間 2,673 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 9 ms
4,376 KB
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 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 8 ms
4,376 KB
testcase_31 AC 8 ms
4,380 KB
testcase_32 AC 4 ms
4,376 KB
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.math;

  int n; rd(n);
  auto a=new int[](n), b=new int[](n);
  foreach(i; 0..n) rd(a[i], b[i]);

  int x=1_000_000_000, dy=1_000_000_000;
  void chmin(int x0, int dy0){
    if(dy0<dy) x=x0, dy=dy0;
    else if(dy0==dy) x=min(x, x0);
  }
  foreach(i; 0..n)foreach(j; 0..i){
    if(b[i]==b[j]){
      if((a[i]-a[j]).abs<=dy) x=1; 
    }else{
      auto g=(b[i]-b[j]).abs;
      auto x0=(a[i]-a[j]).abs/g;
      auto dy1=(a[i]+b[i]*x0-(a[j]+b[j]*x0)).abs;
      auto dy2=(a[i]+b[i]*(x0+1)-(a[j]+b[j]*(x0+1))).abs;
      chmin(x0, dy1); chmin(x0+1, dy2);
    }
  }

  writeln(x);
}

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