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

const int N = 3e5 + 1;
int main() {
    int n, x;
    long long t;
    cin >> n >> x >> t;
    vector <long long> s(n + 1);
    s[0] = 0;
    for (int i=0;i<n;i++){
        int y ;
        cin >> y;
        s[i + 1] = s[i] + y;
    }
    long long div = (t + s[n] + x - 1) / (s [n] + x);
    // 1 2 3 4
    // 1 3 6 10
    int Ans  =0;
    for (int i=1;i<=n + 1;i++){
        long long left_sum = s[i - 1] * div;
        long long right_sum = (s[n] - s[i-1]) * (div - 1);
      //  printf("%I64d %I64d\n", left_sum, right_sum);
        if (left_sum >= t) break;
        if (left_sum + right_sum + div * x >= t && left_sum + right_sum + div * x -x < t) Ans++;
    }
    cout << Ans << endl;
}
Copy
Treasure Random Bruh
GNU G++17
54 ms
2.4 MB
Accepted