Source Code
#include<bits/stdc++.h>
#define _for(i,n) for(int i=0;i<n;i++)
#define _forr(i,n) for(int i=1;i<=n;i++)
#define _rof(i,n) for(int i=n-1;i>=0;i--)
#define _roff(i,n) for(int i=n;i>=1;i--)
#define nl cout << "\n"
#define ff first
#define ss second
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define pb push_back
#define pp pop_back
#define vl vector<ll>
#define lsb(x) (x & ~(x-1))
#define rand(l,r) uniform_int_distribution<int>(l, r)(rng);
#define IOS ios::sync_with_stdio(0); cout.tie(0); cin.tie(0)
#define pause system("pause")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

ll const mod=1e9+7;
ll const mod1=1013;
ll const MX = 2e6+100;

ll n, x, t, a[MX];

int main()
{
    IOS;
    ll sum=0;
    cin>>n>>x>>t;
    _for(i,n)
        cin>>a[i],
        sum+=a[i];
    sum+=x;
    t %= sum;
    if(t==0)
        t=sum;
    sum=0;
    ll ans=0;
    _for(i,n)
    {
        if(sum<t&&sum+x>=t)
            ans++;
        sum+=a[i];
    }
    if(sum<t&&sum+x>=t)
            ans++;
    cout<<ans;
}

/**
Test Case:
*/
Copy
Treasure ShakerOO7
GNU G++17
16 ms
2.3 MB
Accepted