简单思维题

 #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. 【题解】Luogu P5300 [GXOI/GZOI2019]与或和

    原题传送门 我们珂以拆位,拆成一个个0/1矩阵 贡献珂以用全0,全1的子矩阵的个数来计算 全0,全1的子矩阵的个数珂以用悬线法/单调栈解决 #include <bits/stdc++.h> ...

  2. Bootstrap 遮罩插件jquery.mloading

    使用方法 将jquery.mloading.js和jquery.mloading.css引入到页面,调用: $(element).mLoading({ text:"",//加载文字 ...

  3. 《明日方舟》Python版公开招募工具

    工具介绍 根据输入的标签,快速找出能够招募4星,5星干员的标签组合,比如刷出了 重装 | 男 | 支援 |术师 | 先锋 五个标签,输入效果如下: 注意:不支持高级干员和资深高级干员标签 使用环境 安 ...

  4. vue-cli3使用svg

    (根据网上教程实操,仅作个记录) 执行命令安装插件 npm install svg-sprite-loader --save-dev 在vue.config.js中,添加配置 module.expor ...

  5. python测量函数运行时间长度

    python测试函数运行时间长度的方法如下 import time def measure_time(): def wraps(func): def mesure(*args,**kwargs): s ...

  6. 在地址栏里输入一个 URL后,按下 Enter 到这个页面呈现出来,中间会发生什么?

    这是一个面试高频的问题 在输入 URL 后,首先需要找到这个 URL 域名的服务器 IP,为了寻找这个 IP,浏览器首先会寻找缓存,查看缓存中是否有记录,缓存的查找记录为:浏览器缓存 ->系统缓 ...

  7. 【Spring Boot】Spring Boot之跨域解决方案

    一.什么是跨域 跨域,指的是从一个域名去请求另外一个域名的资源.即跨域名请求!跨域时,浏览器不能执行其他域名网站的脚本,是由浏览器的同源策略造成的,是浏览器施加的安全限制. 跨域的严格一点来讲就是只要 ...

  8. ubifs使用方法

    常用命令: 查看块设备分区信息cat /proc/mtd 查看块设备信息mtdinfo /dev/mtd0 格式化mtd分区ubiformat /dev/mtd0 将mtd分区与ubi关联ubiatt ...

  9. Kali下的内网劫持(三)

    前面两种说的是在Kali下的ettercap工具通过配合driftnet和urlsnarf进行数据捕获,接下来我要说的是利用Kali下的另外一种抓包分析工具——wireshark来进行捕获数据: 首先 ...

  10. Eclipse安装JDK11方式

    安装JDK11JDK下载网址:https://www.oracle.com/technetwork/java/javase/downloads Java SE Development Kit 11ht ...