C - Convert to Ones

给你一个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;
}

D - Roman Digits

打表? 问 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)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. Codeforces Round #493 (Div. 1)

    A. /* 发现每次反转或者消除都会减少一段0 当0只有一段时只能消除 这样判断一下就行 */ #include<cstdio> #include<algorithm> #in ...

  4. 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 ...

  5. 【Codeforces Round #493 (Div. 2) B】Cutting

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然只有在前i个位置奇数偶数出现次数都相同的地方才能切. (且不管前面怎么切,这里都能切的. 那么就相当于有n个物品,每个物品的代价 ...

  6. Codeforces Round #493 (Div. 2) A. Balloons 贪心水题

    由于是输出任意一组解,可以将价值从小到大进行排序,第一个人只选第一个,第二个人选其余的.再比较一下第一个人选的元素和第二个人所选元素和是否相等即可.由于已将所有元素价值从小到大排过序,这样可以保证在有 ...

  7. Codeforces Round #493 (Div. 1) B. Roman Digits 打表找规律

    题意: 我们在研究罗马数字.罗马数字只有4个字符,I,V,X,L分别代表1,5,10,100.一个罗马数字的值为该数字包含的字符代表数字的和,而与字符的顺序无关.例如XXXV=35,IXI=12. 现 ...

  8. Codeforces Round #493 (Div. 2) C. Convert to Ones 乱搞_构造_好题

    题意: 给你一个长度为 nnn 的 010101串 ,你有两种操作: 1.将一个子串翻转,花费 XXX 2.将一个子串中的0变成1,1变成0,花费 YYY 求你将这个01串变成全是1的串的最少花费. ...

  9. Codeforces Round #493 (Div. 2) B. Cutting 前缀和优化_动归水题

    不解释,题目过水 Code: #include<cstdio> #include<cmath> #include<algorithm> using namespac ...

随机推荐

  1. if判断条件注意!!!

    if(condition){ console.log(condition为true才执行): } 实际上会对condition执行Boolean()转型函数,将其转换成布尔值

  2. 【Java基础】for循环实现在控制台打印水仙花数

    代码: /* * 需求:在控制台输出所有的”水仙花数” * * 分析: * 什么是水仙花数呢? * 所谓的水仙花数是指一个三位数,其各位数字的立方和等于该数本身. * 举例:153就是一个水仙花数. ...

  3. Debian下配置防火墙iptables

    debian下iptables输入命令后即时生效,但重启之后配置就会消失,可用iptables-save快速保存配置,因为Debian上iptables是不会保存规则的,然后在开机自动的时候让ipta ...

  4. 简单谈谈数据库DML、DDL和DCL的区别

    一.DML DML(data manipulation language)数据操纵语言: 就是我们最经常用到的 SELECT.UPDATE.INSERT.DELETE. 主要用来对数据库的数据进行一些 ...

  5. js auto hover button & html5 button autofocus

    js auto hover button & html5 button autofocus input // html 5 <input name="myinput" ...

  6. Google浏览器解决编码乱码问题

    新版google浏览器编码乱码没有设置的入口,怎么办呢?. 步骤一: 可以下载goole的插件,名为charset,下载后的文件名为Charset_v0.4.1 步骤二: google右上角-> ...

  7. 库存盘点打印功能生成PDF速度太慢使用页面缓存

    一.业务需求 二.产品设计 三.UI设计 四.程序设计 1.使用behavior配置页面缓存 class WmsCheckController extends Controller { /** * @ ...

  8. border-color的深入理解

    .className{ width:100px;height:100px; border:100px solid; border-color: red green blue orange; } 最终的 ...

  9. jQuery代码优化的9种方法

    前面的话 本文将详细介绍jQuery代码优化的9种方法 用对选择器 在jQuery中,可以用多种选择器,选择同一个网页元素.每种选择器的性能是不一样的,应该了解它们的性能差异 1.最快的选择器:id选 ...

  10. SQL to JSON Data Modeling with Hackolade

    Review: SQL to JSON data modeling First, let’s review, the main way to represent relations in a rela ...