Submission

Status:

[P][P][P][P][P][P][P][P][PP][P]

Score: 100

User: Winzzwz

Problemset: กองส้ม

Language: cpp

Time: 0.002 second

Submitted On: 2025-03-05 13:45:44

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int l,n;
stack <int> st;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> l >> n;
    for (int i = l; i >= 1; i--) {
        st.push(i*i);
    }
    while (n && !st.empty()) {
        int top = st.top(); st.pop();
        int minus = min(top,n);
        n -= minus;
        top -= minus;
        //cout << minus << "\n";
        if (top > 0) st.push(top);
    }
    cout << st.size();

    return 0;
}