简单思维题

 #include<bits/stdc++.h>
using namespace std;
#define int long long
#define inf 0x3f3f3f3f3f3f3f
int a[];
signed main(){
int n;cin>>n;
int minx=inf;int x=;
for(int i=;i<=n;i++) {
cin>>a[i];
if(a[i]<minx){
x=i; minx=min(minx,a[i]);
} }
if(n==){
cout<<"-1";
return ;
}
if(n==&&a[]==a[]){
cout<<"-1";return ;
}
cout<<""<<'\n'<<x;
return ;
}

 #include<bits/stdc++.h>

 using namespace std;
#define int long long
int arr[];
int sum[];
signed main(){
int n,m;
cin>>n>>m;int cnt=;
int s=;
for(int i=;i<=n;i++) cin>>arr[i];
for(int i=;i<n;i++){ if(arr[i]%){
s--;
}else{
s++;
}
if(s==&&i!=n){
sum[cnt++]=abs(arr[i+]-arr[i]);
}
}
int add=;
int ans=;
sort(sum,sum+cnt);
/* cout<<cnt<<'\n';
for(int i=0;i<cnt;i++) cout<<sum[i]<<" ";
*/
for(int i=;i<cnt;i++){
add+=sum[i];
if(add>m){
break;
}
ans++;
}
cout<<ans;
return ;
}
/*
10 100
94 65 24 47 29 98 20 65 6 17
*/

//x :翻转
//y :置数
#include<bits/stdc++.h>
using namespace std;
#define int long long signed main(){
int n,x,y;
cin>>n>>x>>y;
string str;
cin>>str;
stack<int> s;
for(int i=;i<str.size();i++){
if(s.empty()){
s.push((str[i]-''));
}else{
int temp=s.top();
if(temp==(str[i]-'')){
continue;
}else{
s.push((str[i]-''));
}
}
}
if(s.size()==&&str[]==''){
cout<<"";
return ;
}int ans=;
if(s.size()%==){ // 偶数
ans=min((s.size()/-)*x+y,s.size()/*y);
cout<<ans;
}else{
int temp=s.top(); if(temp==){
ans=min((s.size()/-)*x+y,(s.size()/)*y);
cout<<ans;
}else{
ans=min(((s.size()/)*x+y),(s.size()/+)*y);
cout<<ans;
}
}
return ;
}
/*
2 0
4 1
6 2
8 3
01011 5 1
011 3 1
0101011
01011
01010 5 2
010 3 1 */

Codeforces Round #493 (Div. 2) 【A,B,C】的更多相关文章

  1. 【CF1256】Codeforces Round #598 (Div. 3) 【思维+贪心+DP】

    https://codeforces.com/contest/1256 A:Payment Without Change[思维] 题意:给你a个价值n的物品和b个价值1的物品,问是否存在取物方案使得价 ...

  2. Codeforces Round #299 (Div. 2)【A,B,C】

    codeforces 535A-水题: #include <bits/stdc++.h> using namespace std; typedef long long LL; char s ...

  3. Codeforces Round #331 (Div. 2)【未完待续】

    http://codeforces.com/problemset/problem/596/B GGGGGGGGGGGGGGGGGGG

  4. Codeforces Round #609 (Div. 2) 【A,B,C】

    题意:给一个n<=1e7,找两个合数a和b使得a-b的差为n. 构造a=3n,b=2n,必含有公因子n,只有当n是1的时候是特例. #include<bits/stdc++.h> u ...

  5. Codeforces Round #443 (Div. 2) 【A、B、C、D】

    Codeforces Round #443 (Div. 2) codeforces 879 A. Borya's Diagnosis[水题] #include<cstdio> #inclu ...

  6. Codeforces Round #436 (Div. 2)【A、B、C、D、E】

    Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...

  7. Codeforces Round #435 (Div. 2)【A、B、C、D】

    //在我对着D题发呆的时候,柴神秒掉了D题并说:这个D感觉比C题简单呀!,,我:[哭.jpg](逃 Codeforces Round #435 (Div. 2) codeforces 862 A. M ...

  8. Codeforces Round #434 (Div. 2)【A、B、C、D】

    Codeforces Round #434 (Div. 2) codeforces 858A. k-rounding[水] 题意:已知n和k,求n的最小倍数x,要求x后缀至少有k个0. 题解:答案就是 ...

  9. Codeforces Round #441 (Div. 2)【A、B、C、D】

    Codeforces Round #441 (Div. 2) codeforces 876 A. Trip For Meal(水题) 题意:R.O.E三点互连,给出任意两点间距离,你在R点,每次只能去 ...

随机推荐

  1. Django框架之第五篇(模板层) --变量、过滤器、标签、自定义标签、过滤器,模板的继承、模板的注入、静态文件

    模板层 模板层就是html页面,Django系统中的(template) 一.视图层给模板传值的两种方法 方式一:通过键值对的形式传参,指名道姓的传参 n = 'xxx'f = 'yyy'return ...

  2. ubuntu supervisor管理uwsgi+nginx

    一.概述 superviosr是一个Linux/Unix系统上的进程监控工具,他/她upervisor是一个Python开发的通用的进程管理程序,可以管理和监控Linux上面的进程,能将一个普通的命令 ...

  3. Redis Cluster: (error) MOVED

      I have a Redis cluster with the following nodes: 192.168.0.14:6379 master (slots from 0 to 16383) ...

  4. ABP 结合 MongoDB 集成依赖注入

    1.我们再ABP项目添加一个.NET Core类库  类库名自定定义, 我这里定义为 TexHong_EMWX.MongoDb 添加NuGet包. ABP mongocsharpdriver 添加 A ...

  5. 如何定位 golang 进程 hang 死的 bug

    之前在 golang 群里有人问过为什么程序会莫名其妙的 hang 死然后不再响应任何请求.单核 cpu 打满. 这个特征和我们公司的某个系统曾经遇到的情况很相似,内部经过了很长时间的定位分析总结,期 ...

  6. selenium中的元素操作之三大等待(一)

    等待时做什么,为什么使用等待 在做自动化测试,设计测试用例的时候,有时下一步的操作会依赖上一步的结果或者内容,上一步操作成功之后才能进行下一步操作等,这时候,我们就需要使用等待,来判断上一步操作是否完 ...

  7. Python的virtualenv管理

    原文链接 虚拟环境 Python 开发中所谓的虚拟环境,就是为 Python 版本及第三方库创建独立的开发环境,使不同项目之间互不干扰.借助于虚拟环境,我们可以在同一台电脑上构建出项目 A 在基于 P ...

  8. docker安装mysql笔记

    首先 查找镜像 docker search mysql 拉取镜像 : docker pull mysql 拉取成功后,查看本地镜像: docker images 可以看到本地有两个镜像(redis是我 ...

  9. 【转载】C#中使用double.Parse方法将字符串转换为双精度double类型

    在C#编程过程中,很多时候涉及到数据类型的转换,例如将字符串类型的变量转换为双精度浮点类型double就是一个常见的类型转换操作,double.Parse方法是C#中专门用来将字符串转换为double ...

  10. .python3基础之“术语表(1)”

    1.注释: 行首有一特殊标志符号运行时告知编程忽略此行:使代码更易于阅读. 例如: #这是一个注释 print("hello world") #print() 方法用于打印输出,p ...