forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path(CODEFORCES) Elections.cpp
52 lines (51 loc) · 987 Bytes
/
(CODEFORCES) Elections.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
45
46
47
48
49
50
51
52
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fastread() (ios_base::sync_with_stdio(false), cin.tie(NULL));
using namespace std;
int main()
{
fastread();
int n;
int a[101];
cin >> n;
int Elodreip = 0, Awruk = 0;
for (int i = 0; i < n; i++)
{
cin >> a[i];
Elodreip += a[i];
}
sort(a, a + n);
int k = a[n - 1];
for (int i = 0; i < n; i++)
{
Awruk += k - a[i];
}
if (Awruk <= Elodreip)
{
Awruk = 0;
while (Awruk < Elodreip)
{
for (int i = 0; i < n; i++)
{
Awruk += k - a[i];
}
if (Awruk > Elodreip)
{
cout << k << endl;
break;
}
else
{
Awruk = 0;
k++;
}
}
}
else
{
cout << k << endl;
}
return 0;
}