Unfortunately we were unable to fully decode your file, as it is not encoded in UTF-8. You can try to decode it yourself by downloading it here.
 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
82
83
84
#include <iostream>
#include <cmath>

using namespace std;

int C(long long int input) //ilo�� 1 w liczbie binarnej na podst dziesi�tnej
{
    int output=0;
    while(true)
    {
    if(input%2==1)
        output++;
    if(input<=1)
        return output;
    input/=2;
    }
}

int main()
{
    int n;
    int place, place2, lap, dod, uj, suma=0;              ///ilo�� sekund
    cin >> n;
    if(n<1||n>200) return 0;
    long int a[n];      ///a[i]== jako�� i-tej sekundy
    long long int m, b[n]; ///m== b.max
    cin >> m;
    if(m<n-1||m>pow(10, 18)) return 0;
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
    }

    for(place=0, lap=0; place<n; place++, lap++) ///najmniejsze warto�ci je�li na samym pocz�ku s� liczby ujemne lub 0
    {
        if(a[place]<=0)
        {
            b[place]=place;
        }
        else break;
    }
    for(place2=n-1, lap=0; place2>=0; place2--, lap++)  ///najwi�ksze warto�ci je�li na ko�cu s� dodatnie
    {
        if(a[place2]>0)
        {
            b[place2]=m-lap;
        }
        else break;
    }

        for(int i=place+1; i<place2; i++)
            {
                if(a[i]>0)
                dod++;
            else
                uj++;
            }
        if(uj>dod)
        {
            for(int i=place; i<place2; i++)
            {
                b[i]=i;
            }
        }
        else
        {
            for(int i=place2; i>=place; i--,place2++)
            {
                b[i]=m-place2;
            }
        }
//    for(int i=0; i<n; i++)
//    {
//        cout << b[i] << "\t";
//    }
    for(int i=0; i<n; i++)
    {
        suma+=a[i]*C(b[i]);
    }

    cout << suma;

    return 0;
}