結果
| 問題 |
No.204 ゴールデン・ウィーク(2)
|
| コンテスト | |
| ユーザー |
jp_ste
|
| 提出日時 | 2019-08-05 05:56:48 |
| 言語 | JavaScript (node v23.5.0) |
| 結果 |
AC
|
| 実行時間 | 74 ms / 1,000 ms |
| コード長 | 1,289 bytes |
| コンパイル時間 | 86 ms |
| コンパイル使用メモリ | 6,820 KB |
| 実行使用メモリ | 43,008 KB |
| 最終ジャッジ日時 | 2024-10-13 01:13:55 |
| 合計ジャッジ時間 | 4,812 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 46 |
ソースコード
function Main(input) {
const data = input.split("\n");
const d = Number(data[0]);
const c = data[1] + data[2];
let realD = d;
let realC = 'x'.repeat(d) + c + 'x'.repeat(d);
let max = 0;
for(var i=0; i<c.length; i++) {
let len = countA(c, i);
max = Math.max(max, len);
i = i + len;
}
for(let j=0; j<d; j++) {
for(let i=0; i<realC.length; i++) {
if(haveLengthX(realC, i, realD)) {
let len = countBeforA(realC, i-1) + realD + countAfterA(realC, i+realD);
max = Math.max(max, len);
}
}
realD--;
}
console.log(max);
}
function countA(list, start) {
let count = 0;
for(let i=start; i<list.length; i++) {
if(list[i] == 'x') return count;
count++;
}
return count;
}
function haveLengthX(list, start, length) {
for(let i=start; i<start+length; i++) {
if(list[i] == 'o') return false;
}
return true;
}
function countAfterA(list, start) {
let count = 0;
for(let i=start; i<list.length; i++) {
if(list[i] == 'x') return count;
count++;
}
return count;
}
function countBeforA(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"));
jp_ste