Skip to main content

两个数列

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

const int N = 2e5 + 10;

int n;
LL s, minv = 0x3f3f3f3f;
int a[N];
vector<LL> b;
vector<LL> sum;

int main () {

cin >> n >> s;

for (int i = 0; i < n ;i ++) {
cin >> a[i];
}
if (n >= 2) {
for (int i = 0; i < n; i++) {
int tmp = 0;
for (int j = 0; j < n; j++) {
if (i == j) continue;
tmp += a[j];
}
sum.push_back(tmp);
}
for (int i = 0; i < n; i++) {
int cnt = 0;
for (int j = 1; j <= a[i]; j++) {
if (s - j > sum[i]) {
cnt ++;
} else if (s - j <= 0) {
cnt++;
}

}
b.push_back(cnt);
}
} else {
int cnt = 0;
for (int i = 0; i < a[0]; i++) {
if (i != s) cnt ++;
}
b.push_back(cnt);
}

for (int i = 0; i < b.size(); i++) cout << b[i] << " ";

return 0;
}

不完善