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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream fout;
ifstream fin;
fin.open("share.in");
fout.open("share.out");
signed int n;
fin>>n;
signed int array1[n];
for(int i=0; i<n; i++)
{
fin >> array1[i];
}
signed int suma=0, sumb=0, sumc=0, a=1, b=1, c=n-2, a1=0, b1=0, c1=0, mikroterosum=1000000000;
while(c>0)
{
while(a1<a)
{
suma+=array1[a1];
a1++;
}
while(b1<b)
{
sumb+=array1[(a1+b1)];
b1++;
}
while(c1<c)
{
sumc+=array1[(a1+b1+c1)];
c1++;
}
if(max(suma,max(sumb,sumc))<=mikroterosum)
{
mikroterosum=min(mikroterosum, max(suma,max(sumb,sumc)));
}
suma=0;
sumb=0;
sumc=0;
a1=0;
b1=0;
c1=0;
c--;
b++;
if(c==0)
{
++a;
b=1;
c=n-a-1;
}
}
fout<<mikroterosum;
fin.close();
fout.close();
return 0;
}
|