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

#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
auto start = chrono::steady_clock::now();
void init_code(){
    fast_io;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
}
int main(){
    init_code();
    long long n,x,t,sum_dig;
    cin>>n>>x>>t;
    sum_dig=x;
    vector<long long> d(n);
    cin>>d[0];
    sum_dig+=d[0];
    for(int i=1;i<n;i++){
        cin>>d[i];
        sum_dig+=d[i];
        d[i]=d[i]+d[i-1];
    }
    long long l=t%sum_dig;
    if(l==0) cout<<1<<endl;
    else{
        int ans=0;
        for(int i=0;i<n;i++){
            if(d[i]<l && d[i]+x>l) ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}
Copy
Treasure bbmm
GNU G++17
1 ms
416 KB
Wrong Answer