B. Mancala (Codeforces Round #478 (Div. 2))

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 const int maxn = 14;
 4 typedef long long ll;
 5 ll a[maxn];
 6 ll b[maxn];
 7 
 8 int main(){
 9     for(int i =0 ;i < maxn;i++){
10         cin >> a[i];
11     }
12     ll ans = -1;
13     for(int i = 0;i < maxn;i++){
14         for(int j = 0;j < maxn;j++) b[j] = a[j];
15         b[i] = 0;
16         int x = a[i] / maxn;
17         int y = a[i] % maxn;
18         for(int j = 0;j < maxn;j++)
19             b[j] += x;
20         for(int j = 1;j <= y;j++)
21             b[(j+i)%maxn]++;
22         ll sum = 0;
23         for(int j = 0;j < maxn;j++)
24             if(b[j]%2 == 0)
25             sum += b[j];
26         if(ans < sum)
27             ans = sum;
28     }
29     cout << ans << endl;
30     return 0;
31 }

B. Mancala

posted @ 2018-05-08 19:35  ouyang_wsgwz  阅读(150)  评论(0编辑  收藏  举报