結果
問題 |
No.406 鴨等間隔の法則
|
ユーザー |
![]() |
提出日時 | 2016-09-21 00:12:49 |
言語 | JavaScript (node v23.5.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 796 bytes |
コンパイル時間 | 151 ms |
コンパイル使用メモリ | 6,696 KB |
実行使用メモリ | 59,084 KB |
最終ジャッジ日時 | 2024-10-12 23:46:16 |
合計ジャッジ時間 | 6,235 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 29 |
ソースコード
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; } } }