結果

問題 No.602 隠されていたゲーム2
ユーザー ikdikd
提出日時 2017-12-02 00:24:21
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 631 bytes
コンパイル時間 935 ms
コンパイル使用メモリ 97,852 KB
実行使用メモリ 6,208 KB
最終ジャッジ日時 2023-09-03 17:09:22
合計ジャッジ時間 2,106 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 7 ms
4,384 KB
testcase_17 AC 12 ms
4,380 KB
testcase_18 AC 30 ms
5,680 KB
testcase_19 AC 34 ms
6,208 KB
testcase_20 AC 31 ms
5,584 KB
testcase_21 AC 21 ms
5,388 KB
testcase_22 WA -
testcase_23 AC 26 ms
5,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

  int n; rd(n);
  auto d=readln.split.to!(int[]);
  int x, y; rd(x, y);
  
  if(x==0 && y==0){writeln(0); return;}
  auto d0=x.abs+y.abs;
  if(count(d, d0)){writeln(1); return;}

  sort(d);
  auto p=assumeSorted(d);
  foreach(i; 0..n){
    if(p.canFind(d0-d[i])){writeln(2); return;}
    if(p.canFind(d0+d[i])){writeln(2); return;}
  }

  writeln(-1);
}

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