結果

問題 No.406 鴨等間隔の法則
ユーザー TksiTksi
提出日時 2018-10-20 00:12:36
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 476 bytes
コンパイル時間 33 ms
コンパイル使用メモリ 6,940 KB
実行使用メモリ 58,292 KB
最終ジャッジ日時 2024-04-21 02:17:53
合計ジャッジ時間 5,149 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
48,532 KB
testcase_01 AC 56 ms
38,912 KB
testcase_02 AC 55 ms
39,680 KB
testcase_03 AC 56 ms
38,912 KB
testcase_04 AC 126 ms
55,976 KB
testcase_05 AC 86 ms
47,756 KB
testcase_06 AC 89 ms
48,064 KB
testcase_07 AC 88 ms
48,088 KB
testcase_08 AC 129 ms
55,896 KB
testcase_09 AC 136 ms
57,060 KB
testcase_10 AC 92 ms
48,404 KB
testcase_11 AC 119 ms
54,116 KB
testcase_12 AC 94 ms
49,392 KB
testcase_13 AC 95 ms
48,760 KB
testcase_14 AC 194 ms
56,444 KB
testcase_15 AC 60 ms
42,368 KB
testcase_16 AC 70 ms
43,520 KB
testcase_17 AC 63 ms
42,624 KB
testcase_18 AC 66 ms
43,392 KB
testcase_19 AC 72 ms
43,992 KB
testcase_20 AC 77 ms
44,544 KB
testcase_21 AC 77 ms
44,544 KB
testcase_22 AC 92 ms
45,452 KB
testcase_23 AC 99 ms
50,476 KB
testcase_24 AC 176 ms
55,088 KB
testcase_25 AC 132 ms
57,124 KB
testcase_26 AC 225 ms
58,168 KB
testcase_27 AC 114 ms
51,984 KB
testcase_28 AC 137 ms
57,208 KB
testcase_29 AC 220 ms
58,292 KB
testcase_30 AC 213 ms
57,616 KB
testcase_31 AC 129 ms
56,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let input = require('fs').readFileSync('/dev/stdin', 'utf8');
let [[N], x] = input.split('\n').map(v => v.split(/\s/).map(v => Number(v)));
if ([...new Set(x)].length != x.length) {
  console.log('NO');
} else {
  x.sort((a, b) => a - b);
  let diff = 0;
  for (let i = 1; i < x.length; i++) {
    if (i == 1) diff = x[i] - x[i - 1];
    else if (i == x.length - 1) console.log('YES');
    else if (diff != x[i] - x[i - 1]) {
      console.log('NO');
      break;
    }
  }
}
0