結果
問題 |
No.185 和風
|
ユーザー |
![]() |
提出日時 | 2021-02-17 01:11:10 |
言語 | TypeScript (5.7.2) |
結果 |
AC
|
実行時間 | 63 ms / 1,000 ms |
コード長 | 801 bytes |
コンパイル時間 | 8,048 ms |
コンパイル使用メモリ | 228,816 KB |
実行使用メモリ | 39,552 KB |
最終ジャッジ日時 | 2024-12-31 16:26:58 |
合計ジャッジ時間 | 9,015 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 |
ソースコード
import * as fs from 'fs'; const input = fs.readFileSync('/dev/stdin', 'utf8'); const arr1 = input.split('\n'); const arr2 = []; const rarr = []; let n = parseInt(arr1[0]); let result = 0; for (let i = 1; i < n + 1; i++) { arr2.push(arr1[i]); } //console.log(arr2);とれてる for (let j = 0; j < n; j++) { const arr3 = arr2[j].split(' '); //console.log(arr3); let result = parseInt(arr3[1]) -parseInt(arr3[0]);//要素は2つって決まってる rarr.push(result); //console.log(rarr);//ここがちがう } for (let k = 0; k < n; k++) { if (rarr[k] === rarr[k + 1]) { result = result + 1; } } if (result === (n - 1)) { if (rarr[0] <= 0) { console.log("-1"); } else { console.log(rarr[0]); } } else { console.log("-1"); }