We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f712d59 commit e4cb0a3Copy full SHA for e4cb0a3
atcoder/abc027/B/main.cpp
@@ -0,0 +1,34 @@
1
+#include <bits/stdc++.h>
2
+
3
+using namespace std;
4
+using ll = int64_t;
5
+using ff = long double;
6
7
+int N;
8
+vector<int> A;
9
10
+int solve() {
11
+ int M = accumulate(A.begin(), A.end(), 0, plus<int>());
12
+ if (M % N != 0) return -1;
13
+ M /= N;
14
15
+ int ans = 0;
16
+ int acc = 0;
17
+ for (auto ai : A) {
18
+ acc += ai - M;
19
+ if (acc != 0) ans += 1;
20
+ }
21
+ return ans;
22
+}
23
24
+int main() {
25
+ ios_base::sync_with_stdio(false);
26
+ cin.tie(0); cout.tie(0);
27
28
+ cin >> N;
29
+ A.assign(N, 0);
30
+ for (auto &ai : A) cin >> ai;
31
+ cout << solve() << endl;
32
33
+ return 0;
34
0 commit comments