Source Code
#define  _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <random>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()* ((uint64_t) new char | 1));
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[]{ -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[]{ 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#else
#endif
}

int main() {
	run();
	int n, x;
	ll t;
	cin >> n >> x >> t;
	vector<ll> d(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> d[i];
		d[i] += d[i - 1];
	}
	ll total = d.back() + x;
	t %= total;
	int cnt = (t <= x);
	for (int i = 1; i <= n && d[i] < t; i++)
		if (t - d[i] <= x)cnt++;
	cout << cnt << endl;
}
Copy
Treasure AhmedEzzatG
GNU G++17
15 ms
2.5 MB
Accepted