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, sum;

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];
    pref[n + 1] = pref[n] + x;

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

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

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