Source Code
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	ll n, x, t;
	cin >> n >> x >> t;
	
	ll sum = x;
	vector <ll> vec(n);
	for (ll& a : vec) {
		cin >> a;
		sum += a;
	}

	t %= sum;
	if (t == 0) t = sum;

	for (int i = 1; i < n; i++)
		vec[i] += vec[i - 1];

	int ans = 0;
	for (int i = 0; i <= n; i++) {
		ll cur = (i ? vec[i - 1] : 0);
		if (cur < t && cur + x >= t)
			ans++;
	}

	cout << ans << '\n';

	return 0;
}
Copy
Treasure Bsher
GNU G++17
18 ms
2.4 MB
Accepted