127552024-12-29 21:46:06xxxVirágos rét (50 pont)cpp17Accepted 50/5018ms508 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
	int n, k;
	cin >> n >> k;
	int sum = 0;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		sum += x;
	}
	if (sum < k) {
		cout << 0 << endl;
		return 0;
	}
	cout << ((sum-k+2)*(sum-k+1))/2 << endl;

}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms320 KiB
2Accepted0/01ms320 KiB
3Accepted0/017ms320 KiB
4Accepted2/21ms320 KiB
5Accepted2/21ms320 KiB
6Accepted2/21ms320 KiB
7Accepted3/31ms320 KiB
8Accepted3/31ms320 KiB
9Accepted3/31ms320 KiB
10Accepted2/21ms320 KiB
11Accepted3/31ms320 KiB
12Accepted2/21ms320 KiB
13Accepted3/31ms508 KiB
14Accepted2/217ms408 KiB
15Accepted2/217ms404 KiB
16Accepted3/317ms396 KiB
17Accepted3/317ms408 KiB
18Accepted3/318ms320 KiB
19Accepted3/317ms500 KiB
20Accepted3/317ms400 KiB
21Accepted3/318ms320 KiB
22Accepted3/317ms408 KiB