Achieve the Goal

· · 个人记录

include<bits/stdc++.h>

using namespace std;

int main() {

int n, k, m;

cin >> n >> k >> m;

int s = 0;

for (int i = 0; i < n - 1; i++) {
    int a;
    cin >> a;
    s += a; 
}
int r = m * n - s;
if (r <= 0) {
    cout << 0 << '\n';
} else if (r > k) {
    cout << -1 << '\n';
} else {
    cout << r << '\n';
}
return 0;

}