网站建设相关合同内容,网站建设中主页指的是,江苏军民融合网站建设,建设部网站危房鉴定标准规定B. Saving the City#xff1a;题目
题意#xff1a;1是炸弹#xff0c;引爆的同时引爆i-1#xff0c;i1#xff0c;埋一个炸弹的成本为b,引爆的成本为a
思路#xff1a;首先如果有炸弹#xff0c;必须引爆一次#xff0c;然后往后遍历#xff0c;看是引爆还是接上的…B. Saving the City题目
题意1是炸弹引爆的同时引爆i-1i1埋一个炸弹的成本为b,引爆的成本为a
思路首先如果有炸弹必须引爆一次然后往后遍历看是引爆还是接上的成本更小就行#include bits/stdc.h
using namespace std;
typedef long long ll;
vectorint a((int)4e5);
vectorint b((int)4e5);
string str;
int main()
{int t;cin t;while (t--){ll a, b;cin a b;cin str;int n str.length();ll res 0, cou 0, ff -1;for (int i 0; i n; i){if (str[i] 1){ff i;break;}}if (ff0) res a;for (int iff;in;i){if (str[i]1) {res min(cou*b,a);cou 0;}else cou;}coutresendl;}
}