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

using namespace std;

int main()
{
    long long n,x,t,sum=0;
    cin>>n>>x>>t;
    long long arr[N+2];
    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
0 ms
0 KB
Compilation Error