codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

975B.md (1837B)


      1 Source: https://codeforces.com/problemset/problem/975/B
      2 
      3 B. Mancala
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes.
     22 
     23  ![](https://espresso.codeforces.com/920ad783d519ca86df1e488b1acd1c886d0e69e5.png) 
     24 
     25 Initially, each hole has $a_i$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction.
     26 
     27 Note that the counter-clockwise order means if the player takes the stones from hole $i$, he will put one stone in the $(i+1)$-th hole, then in the $(i+2)$-th, etc. If he puts a stone in the $14$-th hole, the next one will be put in the first hole.
     28 
     29 After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli.
     30 
     31 Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move.
     32 
     33 Input
     34 
     35 The only line contains 14 integers $a_1, a_2, \ldots, a_{14}$ ($0 \leq a_i \leq 10^9$) — the number of stones in each hole.
     36 
     37 It is guaranteed that for any $i$ ($1\leq i \leq 14$) $a_i$ is either zero or odd, and there is at least one stone in the board.
     38 
     39 Output
     40 
     41 Output one integer, the maximum possible score after one move.
     42 
     43 Examples
     44 
     45 Input
     46 
     47 ```
     48 0 1 1 0 0 0 0 0 0 7 0 0 0 0
     49 ```
     50 
     51 Output
     52 
     53 ```
     54 4
     55 ```
     56 
     57 Input
     58 
     59 ```
     60 5 1 1 1 1 0 0 0 0 0 0 0 0 0
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 8
     67 ```
     68 
     69 Note
     70 
     71 In the first test case the board after the move from the hole with $7$ stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to $4$.