Source Code
#include<bits/stdc++.h>
using namespace std;
#define double long double
#define ll long long
#define Test int T;cin>>T;while(T--)
#define pi acos(-1)
#define endl "\n"
#define fx(x) fixed<<setprecision(x)
#define sz(s) (int)s.size()
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define mem(a,n) memset((a),n,sizeof (a))
#define INF 1e9
#define ii pair<ll,ll>
ll gcd(ll x,ll y){return(!y?x:gcd(y,x%y));}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void file(){
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#else
    //freopen("journey.in", "r", stdin);
    //freopen("journey.out", "w", stdout);
#endif
}
void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    file();
}
int dx[]= {0,0,1,-1};
int dy[]= {-1,1,0,0};
const double eps=1e-9;
const int mod=1e9+7;
const int N=3e5+5;
void solve(){
    ll n,x,t;
    cin>>n>>x>>t;
    ll sum=x;
    vector<ll>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
        sum+=v[i];
    }
    t%=sum;
    ll pre=0;
    int ans=0;
    for(int i=0;i<n;i++){
        if(t>pre&&t<=pre+x)ans++;
        pre+=v[i];
    }
    if(!t||(t>pre&&t<=pre+x))ans++;
    cout<<ans<<endl;
}
int main(){
    fast();
    solve();
    return 0;
}
Copy
Treasure mahmoud_ashour
GNU G++17
16 ms
2.3 MB
Accepted