Last active
December 5, 2015 18:42
-
-
Save saschanaz/762f2ef07a0a9f5c070b to your computer and use it in GitHub Desktop.
paiza
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use strict"; | |
| process.stdin.resume(); | |
| process.stdin.setEncoding('utf8'); | |
| // 自分の得意な言語で | |
| // Let's チャレンジ!! | |
| process.stdin.on('data', function (chunk) { | |
| let items = chunk.split('\n'); | |
| let conditions = items[0].split(' '); | |
| let rangeLength = parseInt(conditions[0]); | |
| let attackLength = parseInt(conditions[1]); | |
| let loopLength = attackLength - rangeLength + 1; | |
| let lastAttack = 0; | |
| for (let i = 1; i <= rangeLength; i++) { | |
| lastAttack += (+items[i]); | |
| } | |
| let maxAttack = lastAttack; | |
| for (let i = 1; i < loopLength; i++) { | |
| lastAttack = lastAttack - parseInt(items[i]) + parseInt(items[i + rangeLength]); | |
| if (lastAttack > maxAttack) { | |
| maxAttack = lastAttack; | |
| } | |
| } | |
| console.log(maxAttack); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment