Source Code
#include <bits/stdc++.h>
using namespace std;

#define FastIO cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
#define LSOne(a) ( (a) & -(a) )
#define SQ(a) (a)*(a)
#define INF  ll(4e18)
#define OO   int(1e9)
#define EPS      1e-9
#define PB  push_back
#define MP  make_pair
#define S      second
#define F       first

typedef long long       ll;
typedef long double     ld;
typedef pair<int , int> ii;
typedef pair<int , ii>  iii;
typedef pair<ll , ll>   pll;
typedef pair<ll , pll>  plll;
typedef vector< int >   vi;
typedef vector< ll >    vl;
typedef vector< ii >    vii;
typedef vector< pll >   vll;
typedef vector< iii >   viii;
typedef vector< plll >  vlll;

const ll MOD = 1e9 + 7;
const ll N = 2e5 + 5e1;

int main()
{
    int n;
    cin >> n;

    ll x ,t;
    cin >> x >> t;

    vl a(n + 1);
    for(int i = 1 ; i <= n ; i++){
        cin >> a[i];
    }

    vl pref(n + 1 ,0);
    for(int i = 1 ; i <= n ; i++){
        pref[i] = pref[i - 1] + a[i];
    }

    int ans = 0;
    for(int i = 1 ; i <= n + 1 ; i++)
    {
        ll s = pref[n] + x;
        ll d = t / s;
        ll m = t % s;

        if( i == n + 1 ){
            if( !m ){
                ans += 1;
                continue;
            }
        }

        if( pref[i - 1] < m && m <= pref[i - 1] + x ){
            ans += 1;
        }
    }

    cout << ans;
    return 0;
}
Copy
Treasure asiseno
GNU G++17
55 ms
4.0 MB
Accepted