forked from fuwutu/CodeForces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
158D - Ice Sculptures.cpp
44 lines (40 loc) · 965 Bytes
/
158D - Ice Sculptures.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//4030436 Jul 6, 2013 2:16:09 PM fuwutu 158D - Ice Sculptures GNU C++0x Accepted 15 ms 100 KB
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
int n, t[20000], sum(0), partsum[20000];
scanf("%d", &n);
for (int i = 0; i < n; ++i)
{
scanf("%d", &t[i]);
sum += t[i];
}
int maximum(sum);
for (int d = 2; d <= n / 3; ++d)
{
if (n % d == 0)
{
fill(partsum, partsum + d, 0);
int x = n / d;
int k = 0;
for (int i = 0; i < x; ++i)
{
for (int j = 0; j < d; ++j)
{
partsum[j] += t[k++];
}
}
for (int j = 0; j < d; ++j)
{
if (partsum[j] > maximum)
{
maximum = partsum[j];
}
}
}
}
printf("%d\n", maximum);
return 0;
}