// Nikita Golikov, 2023 #include using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; #ifdef GOLIKOV #include "/Users/golikovnik/contests/debug.h" #else #define debug(...) ; #endif template bool smin(A& x, B&& y) { if (y < x) { x = y; return true; } return false; } template bool smax(A& x, B&& y) { if (x < y) { x = y; return true; } return false; } int main() { #ifdef GOLIKOV assert(freopen("in", "rt", stdin)); auto _clock_start = chrono::high_resolution_clock::now(); #endif ios::sync_with_stdio(false); cin.tie(nullptr); int n, c; cin >> n >> c; vector a(n); for (auto& x : a) { cin >> x; } debug(a); vector pref(2 * n + 1); for (int i = 0; i + 1 < 2 * n; ++i) { pref[i + 1] = pref[i] + a[i % n]; } pref[2 * n] = 1e18; vector nxt(2 * n); int j = 2 * n; for (int i = 2 * n - 1; i >= 0; --i) { while (j > i && pref[j - 1] - pref[i] >= c) { --j; } nxt[i] = j; } int const LG = 21; int const sz = 2 * n; vector> go(LG, vector(sz + 1)); for (int i = 0; i < sz; ++i) { go[0][i] = nxt[i]; } go[0][sz] = sz; for (int k = 0; k + 1 < LG; ++k) { for (int i = 0; i <= sz; ++i) { go[k + 1][i] = go[k][go[k][i]]; } } for (int s = 0; s < n; ++s) { int const r = s + n; int cnt = 0; int cur = s; for (int b = LG - 1; b >= 0; --b) { int to = go[b][cur]; if (to < r) { cnt += 1 << b; cur = to; } } cout << cnt << ' '; } cout << '\n'; #ifdef GOLIKOV cerr << "Executed in " << chrono::duration_cast( chrono::high_resolution_clock::now() - _clock_start).count() << "ms." << endl; #endif return 0; }