Submission

Status:
[P][P][P][P][P][P][P][P][PP][P]

Score: 100

User: Dormon

Problemset: กองส้ม

Language: cpp

Time: 0.002 second

Submitted On: 2024-11-30 12:49:49

#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>

#define debug(...) Debug(#__VA_ARGS__, __VA_ARGS__)
using namespace std;

template<typename T>
typename std::enable_if<std::is_integral<T>::value>::type
Debug(const char* name, T value) {
    std::cout << name << " : " << value << '\n';
}

template<typename T, typename... Args>
typename std::enable_if<std::is_integral<T>::value>::type
Debug(const char* names, T value, Args... args) {
    const char* comma = strchr(names, ',');
    std::cout.write(names, comma - names) << " : " << value << " | ";
    Debug(comma + 1, args...);
}

void solve(){
    int l, n;
    cin >> l >> n;
    vector<int> pf;
    pf.push_back(0);
    for (int i = 1;i <= 100;i++)
        pf.push_back(i*i+pf.back());
    int k = lower_bound(pf.begin(), pf.end(), n) - pf.begin();
    cout << l - k + (pf[k] != n);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int q = 1; 
    //cin >> q;
    while (q--){
        solve();
    }
}