結果

問題 No.406 鴨等間隔の法則
ユーザー IamAFunOfKonIamAFunOfKon
提出日時 2016-09-21 00:12:49
言語 JavaScript
(node v21.7.1)
結果
WA  
実行時間 -
コード長 796 bytes
コンパイル時間 42 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 57,296 KB
最終ジャッジ日時 2024-04-21 01:25:44
合計ジャッジ時間 5,588 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
49,536 KB
testcase_01 AC 65 ms
40,448 KB
testcase_02 WA -
testcase_03 AC 64 ms
40,576 KB
testcase_04 AC 204 ms
56,040 KB
testcase_05 AC 114 ms
48,384 KB
testcase_06 AC 114 ms
48,896 KB
testcase_07 AC 117 ms
48,896 KB
testcase_08 AC 200 ms
55,644 KB
testcase_09 AC 215 ms
56,336 KB
testcase_10 AC 123 ms
49,408 KB
testcase_11 AC 174 ms
55,988 KB
testcase_12 AC 133 ms
49,920 KB
testcase_13 AC 129 ms
50,048 KB
testcase_14 AC 182 ms
56,336 KB
testcase_15 AC 68 ms
44,288 KB
testcase_16 AC 78 ms
45,824 KB
testcase_17 AC 81 ms
44,544 KB
testcase_18 AC 72 ms
45,568 KB
testcase_19 AC 79 ms
45,952 KB
testcase_20 AC 83 ms
46,080 KB
testcase_21 AC 82 ms
46,208 KB
testcase_22 AC 95 ms
47,616 KB
testcase_23 AC 138 ms
49,864 KB
testcase_24 AC 168 ms
55,272 KB
testcase_25 AC 214 ms
56,496 KB
testcase_26 AC 210 ms
56,400 KB
testcase_27 AC 135 ms
57,296 KB
testcase_28 AC 139 ms
56,496 KB
testcase_29 AC 210 ms
56,144 KB
testcase_30 AC 209 ms
56,480 KB
testcase_31 AC 211 ms
56,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var counter = 0;
reader.on('line', function (line) {
  counter += 1;
  lines.push(line);
  if( counter == 2){
    main();
    process.exit(0);
  }
});
process.stdin.on('end', function () {
});

function main(){
  var n = parseInt(lines[0]);
  var xs = [];
  lines[1].split(" ").map(function(x) {
    xs.push(parseInt(x));
  });
  xs.sort(function(a,b){
    if(a < b) return -1;
    if(a > b) return 1;
    return 0;
  });
  var sa = xs[1] - xs[0];
  if(sa == 0){
    console.log("NO");
    return 0;
  }
  for(var i = 1; i < n - 1; ++i){
    if(sa != xs[i + 1] - xs[i]){
      console.log("NO");
      return 0;
    }else{
      console.log("YES");
      return 0;
    }
  }
}
0