Source Code
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n))
typedef bitset<10> MASK;

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int main() {
    fast();
    ll n, x, t;
    cin >> n >> x >> t;
    ll cur = 0, ans = 0, total = x;
    ll arr[n];
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        total += arr[i];
    }
    for (int i = 0; i <= n; ++i) {
        ll rem = t - (cur + x);
//        cout<<rem<<" "<<total<<endl;
            if (rem < 0 || rem % total == 0 || (rem % total) > total - x) ans++;
        if (i == n)break;
        cur += arr[i];
        if(cur>=t)break;
    }
    cout << ans;
}
Copy
Treasure 7eem
GNU G++17
17 ms
2.4 MB
Accepted