#include using namespace std; typedef long long ll; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b MA[3]; int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); int N,A,B;cin>>N>>A>>B; string S;cin>>S; vector X; int i=0; while(i+21){ int mid=(left+right)/2; int taA,taB; taA=(mid+1)/2; taB=mid/2; if(sw) swap(taA,taB); priority_queue> PQ; for(int x:X) PQ.push(mp(x%A,x)); int cn=0; vector Y; while(!PQ.empty()){ if(cn==taB) break; auto u=PQ.top();PQ.pop(); int x=u.se; if(x>=B){ x-=B; cn++; PQ.push(mp(x%A,x)); }else{ Y.push_back(x); } } if(cn==taB){ int can=0; while(!PQ.empty()){ auto u=PQ.top();PQ.pop(); int x=u.se; can+=x/A; } for(int y:Y) can+=y/A; if(can>=taA){ left=mid; }else{ right=mid; } }else{ right=mid; } } if(sw){ swap(A,B); } chmax(ans,left); } { bool sw=false; if(A>B){ swap(A,B); sw=true; } int left=0,right=N+1; while(right-left>1){ int mid=(left+right)/2; int taA,taB; taA=(mid+1)/2; taB=mid/2; if(sw) swap(taA,taB); priority_queue> PQ; for(int x:X) PQ.push(mp(x%A,x)); int cn=0; vector Y; while(!PQ.empty()){ if(cn==taB) break; auto u=PQ.top();PQ.pop(); int x=u.se; if(x>=B){ x-=B; cn++; PQ.push(mp(x%A,x)); }else{ Y.push_back(x); } } if(cn==taB){ int can=0; while(!PQ.empty()){ auto u=PQ.top();PQ.pop(); int x=u.se; can+=x/A; } for(int y:Y) can+=y/A; if(can>=taA){ left=mid; }else{ right=mid; } }else{ right=mid; } } chmax(ans,left); } cout<