Source Code
#include "bits/stdc++.h"

#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O2")

using namespace std;
using ll = long long;
using ld = long double;

int dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
int dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

const int N = 2E5 + 5, M = 2E6 + 10, MOD = 1E9 + 7, OO = 0x3f3f3f3f;
ll n, x, t, d[N], pref[N], ans, s;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    cin >> n >> x >> t;
    for (int i = 1; i <= n; ++i)
        cin >> d[i], pref[i] = d[i] + pref[i-1];

    for (int i = 0; i <= n; ++i)
        if(pref[i] < t && pref[i] + x >= t) ans++;

    if(ans == 0 && pref[n] < t){
        s = t / pref[n];
        s *= pref[n];
        for (int i = 0; i <= n; ++i)
            if(s + pref[i] < t && s + pref[i] + x >= t) ans++;
    }
    cout << ans;

    return 0;
}
Copy
Treasure Redhwan
GNU G++17
0 ms
780 KB
Wrong Answer