Language: C++

#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
using namespace std;

int main()
{
    // 整数の入力
    long long remain,i,N,temp,A,B,kari,remainCount,ACount,total,minBOnly,BOnlyCount,maxAOnly,AOnlyCount,minHP;
    bool endFlag = false;
    maxAOnly = 0;
    vector<long long> hitpoints;
    cin >> N >> A >> B;

    for (i=0;i<N;i++){
        cin >> temp;
        hitpoints.push_back(temp);
        AOnlyCount = temp/ A + (temp % A != 0);
        if (AOnlyCount > maxAOnly){
            maxAOnly = AOnlyCount;
        }
    }

    sort(hitpoints.begin(),hitpoints.end(),greater<long long>());

    total = maxAOnly;
    ACount = 0;
    for (i=0;i<N;i++){
        hitpoints[i]+= - maxAOnly*B;
        if (hitpoints[i] > 0){
            ACount += hitpoints[i] / (A - B) + (hitpoints[i] % (A - B) != 0);
        }
    }
    if (ACount <= total){
        endFlag = true;
    }

    while (!endFlag){
        remain = - total * (A - B);
        remainCount = 0;
        ACount = 0;
        minBOnly = 1000000001;
        minHP = 1000000001;
        for (i=0;i<N;i++){
            if (hitpoints[i] > 0){
                remain += hitpoints[i];
                BOnlyCount = hitpoints[i] / B + (hitpoints[i] % B != 0);
                minHP = hitpoints[i];
                if (BOnlyCount < minBOnly){
                    minBOnly = BOnlyCount;
                }
                remainCount +=1;
            }else{
                break;
            }
        }

        kari = max({remain / (A + (remainCount-1) * B) + (remain % (A + (remainCount-1) * B) != 0),
                   min(minBOnly,remainCount - total)},
                   (minHP + total * B)/(A + (remainCount-1) * B) * remainCount );
        total += kari;
        for (i=0;i<N;i++){
            hitpoints[i]+= - kari*B;
            if (hitpoints[i] > 0){
                ACount += hitpoints[i] / (A - B) + (hitpoints[i] % (A - B) != 0);
            }else{
                break;
            }
        }

        if (ACount <= total){
            endFlag = true;
        }
    }
    cout << total << endl;
    return 0;
}

Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = const long long int*; _Iterator2 = const long long int*; _Compare = long long int]':
/usr/include/c++/14/bits/stl_algo.h:5626:12:   required from 'constexpr _ForwardIterator std::__max_element(_ForwardIterator, _ForwardIterator, _Compare) [with _ForwardIterator = const long long int*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<long long int>]'
 5626 |         if (__comp(__result, __first))
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5719:44:   required from 'constexpr _Tp std::max(initializer_list<_Tp>, _Compare) [with _Tp = long long int; _Compare = long long int]'
 5719 |       return *_GLIBCXX_STD_A::__max_element(__l.begin(), __l.end(),
      |                                            ^
a.cc:60:19:   required from here
   60 |         kari = max({remain / (A + (remainCount-1) * B) + (remain % (A + (remainCount-1) * B) != 0),
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   61 |                    min(minBOnly,remainCount - total)},
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   62 |                    (minHP + total * B)/(A + (remainCount-1) * B) * remainCount );
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: expression cannot be used as a function
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~