Codeforces Round #493 (Div. 2)
给你一个01串 x是反转任意子串的代价 y是将子串全部取相反的代价 问全部变成1的最小代价
两种可能 一种把1全部放到一边 然后把剩下的0变成1 要么把所有的 0 直接变成1
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int main(){
LL n,x,y;
string a;
cin>>n>>x>>y>>a;
;
LL s=,s1=;
;j<a.size();j++){
'&&fa) continue;
){
s++;
fa=;
};
}
LL l=a.size();
LL ans=;
]==]=='){
s1=s+;
ans=x*s;
}]==]==]==]=='){
s1=s;
ans=x*(max(1LL*,s-));
}]==]=='){
s1=max(1LL*,s-);
ans=x*(max(1LL*,s-));
}
ans+=y;
ans=min(ans,y*s1);
cout<<ans<<endl;
}
打表? 问 n个字符 能组成几个数
#include<bits/stdc++.h>
using namespace std;
#define LL long long
]={,,,,,,,,,,,};
int main() {
LL n;
scanf("%lld",&n);
) printf("%d\n",ans[n]);
+(n-)*);
;
}
Codeforces Round #493 (Div. 2)的更多相关文章
- Codeforces Round #493 (Div 2) (A~E)
目录 Codeforces 998 A.Balloons B.Cutting C.Convert to Ones D.Roman Digits E.Sky Full of Stars(容斥 计数) C ...
- Cutting Codeforces Round #493 (Div. 2)
Cutting There are a lot of things which could be cut — trees, paper, “the rope”. In this problem you ...
- Codeforces Round #493 (Div. 1)
A. /* 发现每次反转或者消除都会减少一段0 当0只有一段时只能消除 这样判断一下就行 */ #include<cstdio> #include<algorithm> #in ...
- Codeforces Round #493 (Div. 2)D. Roman Digits 第一道打表找规律题目
D. Roman Digits time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- 【Codeforces Round #493 (Div. 2) B】Cutting
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然只有在前i个位置奇数偶数出现次数都相同的地方才能切. (且不管前面怎么切,这里都能切的. 那么就相当于有n个物品,每个物品的代价 ...
- Codeforces Round #493 (Div. 2) A. Balloons 贪心水题
由于是输出任意一组解,可以将价值从小到大进行排序,第一个人只选第一个,第二个人选其余的.再比较一下第一个人选的元素和第二个人所选元素和是否相等即可.由于已将所有元素价值从小到大排过序,这样可以保证在有 ...
- Codeforces Round #493 (Div. 1) B. Roman Digits 打表找规律
题意: 我们在研究罗马数字.罗马数字只有4个字符,I,V,X,L分别代表1,5,10,100.一个罗马数字的值为该数字包含的字符代表数字的和,而与字符的顺序无关.例如XXXV=35,IXI=12. 现 ...
- Codeforces Round #493 (Div. 2) C. Convert to Ones 乱搞_构造_好题
题意: 给你一个长度为 nnn 的 010101串 ,你有两种操作: 1.将一个子串翻转,花费 XXX 2.将一个子串中的0变成1,1变成0,花费 YYY 求你将这个01串变成全是1的串的最少花费. ...
- Codeforces Round #493 (Div. 2) B. Cutting 前缀和优化_动归水题
不解释,题目过水 Code: #include<cstdio> #include<cmath> #include<algorithm> using namespac ...
随机推荐
- Eclipse的智能提示的设置
智能提示修改方式是: Windows——>Preferences——>Java-->Editor-->Content Asist,在Auto activation trigge ...
- 简单谈谈数据库DML、DDL和DCL的区别
一.DML DML(data manipulation language)数据操纵语言: 就是我们最经常用到的 SELECT.UPDATE.INSERT.DELETE. 主要用来对数据库的数据进行一些 ...
- Navicat Preminum
此软件在连接的时候,需要这样: 新建链接==>连接属性==>编码选择自动==>如果此时点击确定的话,会把整个服务器的所有数据库都打开, 我们也可以只打开指定的数据库, 点击高级==& ...
- 莫烦keras学习自修第三天【回归问题】
1. 代码实战 #!/usr/bin/env python #!_*_ coding:UTF-8 _*_ import numpy as np # 这句话不知道是什么意思 np.random.seed ...
- python设计模式第九天【策略模式】
1. 定义 对一系列算法进行封装,为所有算法定义一个抽象的算法接口,可以平滑的进行算法切换 2. 策略模式的UML图 3.代码实现 #!/usr/bin/env python #! _*_ codin ...
- Python——线程1
多线程并发 from threading import Thread import time #多线程并发 def func(n): time.sleep(1) print(n) for i in r ...
- zookeeper客户端操作
ZooKeeper客户端 zkCli.sh 节点的增删改查 在 bin 目录下的 zkCli.sh 就是ZooKeeper客户端 ./zkCli.sh -timeout 5000 -server ...
- 如何使用CSS 让Table的最后一列的右边框不显示
table{ border-collapse:collapse; } .templateColumn{ border-right:1px solid #AAA; } table.templateCon ...
- Windows Server2008、IIS7启用CA认证及证书制作完整过程
1 添加活动目录证书服务 1.1 打开服务器管理器,右键点击角色,选择“添加角色”,在“添加角色向导”窗口左侧面板选择“服务器角色”,然后勾选“Active Dire ...
- [离散时间信号处理学习笔记] 10. z变换与LTI系统
我们前面讨论了z变换,其实也是为了利用z变换分析LTI系统. 利用z变换得到LTI系统的单位脉冲响应 对于用差分方程描述的LTI系统而言,z变换将十分有用.有如下形式的差分方程: $\displays ...