标签:clu can include scan while 题意 cin bit com
第一题:读题+基础贪心
http://codeforces.com/contest/1207
第二题:思维题
题意:对于
第三题:
大佬们的dp写法:
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e5+5; const int inf = 0x3f3f3f3f; ll T, n, a, b, dp[maxn][2]; char s[maxn]; int main() { cin >> T; while(T--) { memset(dp, inf, sizeof(dp)); cin >> n >> a >> b; scanf("%s", s+1); dp[0][0] = b; for (int i = 1; i <= n; i++) { if (s[i] == ‘0‘) { dp[i][0] = min(dp[i][0], dp[i-1][0]+a+b); dp[i][0] = min(dp[i][0], dp[i-1][1]+2*a+2*b); dp[i][1] = min(dp[i][1], dp[i-1][0]+2*a+b); } dp[i][1] = min(dp[i][1], dp[i-1][1]+a+2*b); } cout << dp[n][0] << endl; } return 0; }
标签:clu can include scan while 题意 cin bit com
原文地址:https://www.cnblogs.com/Aiahtwo/p/11407242.html