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

using namespace std;
const int N = 200000;
long long arr[N+2];
int main() {

   long long n,x,t,sum=0;
    cin>>n>>x>>t;
    sum += arr[n];
    for(long long i=1;i<n+1;i++)
    {
        cin>>arr[i];
        arr[i] += arr[i-1];
    }
    arr[n+1]=arr[n]+x;
    t %= arr[n+1];
    if(t==0)
    {
        cout<<"1"<<endl;
        return 0;
    }
    else
    {
        long long ans = 0;
        for(int i=0;i<n+1;i++)
        {
            if(arr[i]<t&&arr[i]+x>=t)
                ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}
Copy
Treasure Mohamedmaher
GNU G++17
87 ms
2.6 MB
Accepted