Created
          February 2, 2015 09:41 
        
      - 
      
- 
        Save orleika/4c52ff7f9d5036244c0c to your computer and use it in GitHub Desktop. 
     paizaオンラインハッカソン4 Lite
  
        
  
    
      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
    
  
  
    
  | process.stdin.resume(); | |
| process.stdin.setEncoding('utf8'); | |
| var input_lines = ''; | |
| var parseInt10 = function (v) { | |
| return parseInt(v, 10); | |
| } | |
| process.stdin.on('data', function (chunk) { | |
| input_lines += chunk; | |
| }); | |
| process.stdin.on('end', function () { | |
| var lines = input_lines.trim().split("\n"), | |
| p = lines[0].split(" ").map(parseInt10), | |
| v = lines.slice(1, p[1] + 1).map(parseInt10), | |
| ans, tmp, i; | |
| ans = v.slice(0, p[0]).reduce(function (a, b) { return a + b; } ); | |
| for (i = 0, tmp = ans; i < p[1] - p[0]; i++) { | |
| tmp += v[i+p[0]] - v[i]; | |
| if (ans < tmp) ans = tmp; | |
| } | |
| console.log(ans); | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment