結果

問題 No.406 鴨等間隔の法則
ユーザー IamAFunOfKonIamAFunOfKon
提出日時 2016-09-21 00:17:42
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 246 ms / 2,000 ms
コード長 787 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 7,076 KB
実行使用メモリ 57,296 KB
最終ジャッジ日時 2024-04-21 01:25:34
合計ジャッジ時間 7,020 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
49,920 KB
testcase_01 AC 72 ms
40,832 KB
testcase_02 AC 77 ms
40,448 KB
testcase_03 AC 72 ms
40,576 KB
testcase_04 AC 225 ms
56,300 KB
testcase_05 AC 125 ms
48,896 KB
testcase_06 AC 129 ms
49,792 KB
testcase_07 AC 128 ms
49,536 KB
testcase_08 AC 222 ms
56,540 KB
testcase_09 AC 234 ms
56,588 KB
testcase_10 AC 136 ms
49,792 KB
testcase_11 AC 199 ms
56,632 KB
testcase_12 AC 148 ms
50,816 KB
testcase_13 AC 144 ms
50,176 KB
testcase_14 AC 207 ms
56,976 KB
testcase_15 AC 78 ms
44,928 KB
testcase_16 AC 85 ms
45,824 KB
testcase_17 AC 78 ms
44,544 KB
testcase_18 AC 83 ms
45,952 KB
testcase_19 AC 92 ms
46,336 KB
testcase_20 AC 96 ms
47,104 KB
testcase_21 AC 96 ms
46,720 KB
testcase_22 AC 108 ms
48,000 KB
testcase_23 AC 157 ms
50,632 KB
testcase_24 AC 191 ms
55,400 KB
testcase_25 AC 246 ms
56,752 KB
testcase_26 AC 239 ms
57,040 KB
testcase_27 AC 150 ms
57,296 KB
testcase_28 AC 155 ms
56,880 KB
testcase_29 AC 242 ms
57,040 KB
testcase_30 AC 234 ms
56,612 KB
testcase_31 AC 227 ms
56,928 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;
    }   
  }
  console.log("YES");
  return 0;
}
0