Can I use Chinese?
这个题是一道二分题目
he question is a two-point question.
题意很简单,不需要解释了
It is very simple, do not need to explain.
但是我一直没过样例,原因是我的变量类型搞错了
But I haven't had the sample because my variables are wrong.
应该是long long,但是我写成了int
It should be long long, but I use the int.
下面是代码
Next is my code.
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int q[5]; // B C S
int c[5];
int m[5];
char s[110];
int B,C,S;
long long tot,ans;
int check(long long n)
{
long long tmp=tot;
if(n*c[1]>q[1]) tmp-=(n*c[1]-q[1])*m[1];
if(n*c[2]>q[2]) tmp-=(n*c[2]-q[2])*m[2];
if(n*c[3]>q[3]) tmp-=(n*c[3]-q[3])*m[3];
if(tmp>=0)
return 1;
else
return 0;
}
int main()
{
cin>>s;
for(int i=0;i<strlen(s);i++)
{
if(s[i]=='B') c[1]++;
if(s[i]=='S') c[2]++;
if(s[i]=='C') c[3]++;
}
cin>>q[1]>>q[2]>>q[3];
cin>>m[1]>>m[2]>>m[3];
cin>>tot;
int d=tot;
long long l=1,r=2333333333333;
long long mid;
while(l<=r)
{
mid=(l+r)/2;
if(check(mid))
l=mid+1,ans=mid;
else r=mid-1;
}
cout<<ans;
return 0;
}



