#include using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); //客i+X+Yの部屋は客iの部屋と同じ ll n, x, y, z, p, ans=0; char c; cin >> n >> x >> y; z = x+y; vector a(z), b(z); //a[i]=z周期でaを望む客の数の和 for (int i=0; i> p >> c; if (c == 'A') a[i%z]+=p; else b[i%z]+=p; } //始め、全員Aの部屋にいる for (int i=0; i d(z); for (int i=0; i()); for (int i=0; i