結果
| 問題 |
No.406 鴨等間隔の法則
|
| コンテスト | |
| ユーザー |
IamAFunOfKon
|
| 提出日時 | 2016-09-21 00:17:42 |
| 言語 | JavaScript (node v23.5.0) |
| 結果 |
AC
|
| 実行時間 | 232 ms / 2,000 ms |
| コード長 | 787 bytes |
| コンパイル時間 | 146 ms |
| コンパイル使用メモリ | 6,688 KB |
| 実行使用メモリ | 59,080 KB |
| 最終ジャッジ日時 | 2024-10-12 23:46:01 |
| 合計ジャッジ時間 | 6,731 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| 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;
}
}
console.log("YES");
return 0;
}
IamAFunOfKon