Source Code
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <numeric>
#include <chrono>
#include <random>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <unordered_map>
#include <cstring>
#include <cassert>
#include <climits>
#include <complex>
#include <math.h>
using namespace std;

const int N = 2e5 + 10, mod = 1e9 + 7;

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1;
    for(int cn = 1; cn <= tc; cn++) {
        int n, x;
        long long t;
        scanf("%d%d%lld", &n, &x, &t);

        long long sumD = 0;
        vector<int> d(n);
        for (int i = 0; i < n; i++) {
            scanf("%d", &d[i]);
            sumD += d[i];
        }

        sumD += x;
        long long steps = t / sumD;
        t -= steps * sumD;

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

            t -= d[i];
        }

        if (t > 0 && x >= t) ans++;

        printf("%d\n", ans);
    }
    return 0;
}
Copy
Treasure amr962
GNU G++17
20 ms
1.5 MB
Accepted