結果
問題 |
No.204 ゴールデン・ウィーク(2)
|
ユーザー |
![]() |
提出日時 | 2019-08-05 04:29:03 |
言語 | JavaScript (node v23.5.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 849 bytes |
コンパイル時間 | 36 ms |
コンパイル使用メモリ | 6,692 KB |
実行使用メモリ | 41,588 KB |
最終ジャッジ日時 | 2024-10-13 01:13:22 |
合計ジャッジ時間 | 4,436 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 31 |
ソースコード
function Main(input) { const data = input.split("\n"); const d = Number(data[0]); const c = data[1] + data[2]; let max = 0; for(let i=0; i<c.length-d; i++) { if(haveLength(c, i, d)) { const len = countBefor(c, i-1) + d + countAfter(c, i+d); max = Math.max(max, len); } } console.log(max); } function haveLength(list, start, length) { for(let i=start; i<start+length; i++) { if(list[i] == 'o') return false; } return true; } function countAfter(list, start) { let count = 0; for(let i=start; i<list.length; i++) { if(list[i] == 'x') return count; count++; } return count; } function countBefor(list, start) { let count = 0; for(let i=start; i>=0; i--) { if(list[i] == 'x') return count; count++; } return count; } Main(require("fs").readFileSync("/dev/stdin", "utf8"));