简单思维题

 #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. elasticsearch安全重启节点

    elasticsearch集群,有时候可能需要修改配置,增加硬盘,扩展内存等操作,需要对节点进行维护升级.但是业务不能停,如果直接kill掉节点,可能导致数据丢失.而且集群会认为该节点挂掉了,就开始转 ...

  2. 基于Spark2.X系列的累加器和Streaming基础

    一.累加器API 关于累加器,前面我也写了一篇博客,顺便粘贴这儿,对比学习,Spark学习之编程进阶总结(一).Spark 2.0系列引入了一个更加简单和更高性能的累加器API,如在1.X版本中可以这 ...

  3. GreenPlum 最佳实践

    数据模型 Greenplum数据库是一种shared nothing的分析型MPP数据库.这种模型与高度规范化的/事务型的SMP数据库有显著区别.Greenplum数据库使用非规范化的模式设计会工作得 ...

  4. jQuery.Form.js使用方法

    一.jQuery.Form.js 插件的作用是实现Ajax提交表单. 方法: 1.formSerilize() 用于序列化表单中的数据,并将其自动整理成适合AJAX异步请求的URL地址格式. 2.cl ...

  5. The underlying connection was closed: An unexpected error occurred on a rece

    服务器问题,在后台访问外网了,特别是https的网站,容易出这个问题. 修改服务器配置,或修改代码解决.

  6. 如何在linux中重置Mysql访问密码

    目录 跳过密码认证 重启MySQL: 用sql来修改root的密码 去掉'跳过密码'代码 假设我们使用的是root账户. 跳过密码认证 重置密码的第一步就是跳过MySQL的密码认证过程,方法如下: # ...

  7. 【开发笔记】- 转义html特殊字符

    package com.juihai.util; import org.apache.commons.lang.StringUtils; import org.springframework.web. ...

  8. 1.Javascript实现Symbol

    // 当调用 Symbol 的时候,会采用以下步骤: //1. 如果使用 new ,就报错 //2. 如果 description 是 undefined,让 descString 为 undefin ...

  9. php xml解析

    XML处理是开发过程中经常遇到的,PHP对其也有很丰富的支持,本文只是对其中某几种解析技术做简要说明,包括:Xml parser, SimpleXML, XMLReader, DOMDocument. ...

  10. Android为TV端助力之点击Textview无效

    记录一下如果有两个Textview都有点击事件,那么不能给Textview同时设置 android:focusable="true"android:focusableInTouch ...