Source Code
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

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

    ll k;
    cin >> k;

    ll total = m;
    vector<int> a(n);
    for (int& x : a) {
        scanf("%d", &x);
        total += x;
    }

    ll weeks = (k - 1) / total;
    k -= weeks * total;

    int answer = 0;

    for (int i = 0; i <= n; i++) {
        if (k > 0 && k <= m) {
            answer++;
        }

        if (i < n) {
            k -= a[i];
        }
    }

    cout << answer << endl;
}
Copy
Treasure Baraa_Armoush
GNU G++17
22 ms
1.6 MB
Accepted