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

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;

const double pi = acos(-1);
const int N = 1e6 + 6, mod = 998244353, M = 1e7 + 7;
const ll MAX = 5e18;

int n, x, d[N], ans;
ll t, v;

int main()
{
    scanf("%d%d%lld", &n, &x, &t);
    v = x;
    for(int i = 0; i < n; i++){
        scanf("%d", d + i);
        v += d[i];
    }
    t %= v;
    if(!t)
        t += v;
    for(int i = 0; i < n; i++){
        ans += (t - x) <= 0;
        t -= d[i];
        if(t <= 0)
            break;
    }
    if(t > 0)
        ans += (t - x) <= 0;
    cout << ans;
    return 0;
}
Copy
Treasure princ_iple
GNU G++17
35 ms
1.6 MB
Accepted