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

using namespace std;
ll MOD = 1e9 + 7 ;
ll bigMod(ll x,ll y){
    if (y == 0)return 1;
    if (y == 1)return x;
    ll res = bigMod(x , y / 2LL);
    res *= res;
    res %= MOD;
    if (y % 2){
        res *= x;
        res %= MOD;
    }
    return res;
}
ll fac[1000005];
ll choose(ll x,ll y){
    if (x == y)return 1;
    if (y > x)return 0;
    if (y == 0)return 1;
    ll up = fac[x];
    ll down = fac[y] * fac[x-y];
    down %= MOD;
    ll ret = up * bigMod(down , MOD - 2);
    ret %= MOD;
    return ret;
}

ll n , x , t , d[200005];
ll pre[200005];

ll sum;
int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> x >> t;
    for (int i=1;i<=n;i++){
        cin >> d[i];
        sum += d[i];
        pre[i] = pre[i-1];
        pre[i] += d[i];
    }
    sum += x;
    ll u = t % sum;
    int ans = 0;
    if (u == 0)u = sum;
    for (int i=1;i<=n;i++){
        ll l = pre[i-1] + 1;
        ll r = pre[i-1] + x;
        if (l <= u && u <= r)ans++;
    }
    ll l = pre[n] + 1;
    ll r = sum;
    if (l <= u && u <= r)ans++;
    cout << ans << endl;
    return 0;
}
Copy
Treasure Khaled97ha
GNU G++17
19 ms
4.0 MB
Accepted