Source Code
#include<bits/stdc++.h>
#define all(s) s.begin(), s.end()
#define sz(s) (int) s.size()
using namespace std;
void DeathRoad(){
    int n;
    long long x, t; cin >> n >>  x >> t;
    vector<int> v(n + 5);
    long long total = x, preSum = 0;
    for(int i = 1; i <= n; i++){
        cin >> v[i];
        total += v[i];
    }
    long long res = t % total;
    if(res == 0)
     res = total;
    int ans = 0;
    for(int i = 1; i <= n + 1; i++){
        if((res - preSum) >= 1 && (res - preSum) <= x)
            ans++;
        preSum += v[i];
    }
    cout << ans;
}
int main() {
    ios_base::sync_with_stdio(0);
    
    int T = 1;
    //cin >> T;
    while (T--)
        DeathRoad();
    return 0;
}
/***
        We're here for death, so let's go to it together!
***/
 
Copy
Treasure MhmudAbdGhafar
GNU G++17
17 ms
1.5 MB
Accepted