Source Code
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;

ll get(ll n){
    return (n*(n+1))/2;
}

ll pre[N],suf[N],a[N];

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,x,t;
    cin>>n>>x>>t;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        pre[i]=pre[i-1]+a[i];
    }
    ll C=t/(pre[n]+x);
    t=t-((pre[n]+x)*C);
    if(t==0){
        cout<<1<<'\n';
        return 0;
    }
    int ans=0;
    for(int i=1;i<=n+1;i++){
        if(t-pre[i-1]>0){
            ll c=t-(pre[i-1]+x);
            if(c<=0){
                ans++;
            }
        }
    }
    cout<<ans<<'\n';   
}
Copy
Treasure Ahmed_Allawati
GNU G++17
18 ms
4.0 MB
Accepted