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

简单思维题
#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】的更多相关文章
- 【CF1256】Codeforces Round #598 (Div. 3) 【思维+贪心+DP】
https://codeforces.com/contest/1256 A:Payment Without Change[思维] 题意:给你a个价值n的物品和b个价值1的物品,问是否存在取物方案使得价 ...
- Codeforces Round #299 (Div. 2)【A,B,C】
codeforces 535A-水题: #include <bits/stdc++.h> using namespace std; typedef long long LL; char s ...
- Codeforces Round #331 (Div. 2)【未完待续】
http://codeforces.com/problemset/problem/596/B GGGGGGGGGGGGGGGGGGG
- 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 ...
- Codeforces Round #443 (Div. 2) 【A、B、C、D】
Codeforces Round #443 (Div. 2) codeforces 879 A. Borya's Diagnosis[水题] #include<cstdio> #inclu ...
- Codeforces Round #436 (Div. 2)【A、B、C、D、E】
Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...
- Codeforces Round #435 (Div. 2)【A、B、C、D】
//在我对着D题发呆的时候,柴神秒掉了D题并说:这个D感觉比C题简单呀!,,我:[哭.jpg](逃 Codeforces Round #435 (Div. 2) codeforces 862 A. M ...
- 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. 题解:答案就是 ...
- Codeforces Round #441 (Div. 2)【A、B、C、D】
Codeforces Round #441 (Div. 2) codeforces 876 A. Trip For Meal(水题) 题意:R.O.E三点互连,给出任意两点间距离,你在R点,每次只能去 ...
随机推荐
- c++11多线程记录2:线程管理
线程没有调用join和detach thread对象必须调用join或者detach,否则程序会终止 例如: void func() { std::cout << "hello, ...
- stvd使用中的一些问题
1.stm8_interrupt_vector.c 会莫名其妙的自动出现,而且都是在项目目录下.进行如下操作 2.stvd编译时遇到no default placement for segment . ...
- svg 直线水平渐变为什么没有效果,必须得是一条倾斜的不水平的直线才有渐变效果呢??
参考:https://blog.csdn.net/u012260672/article/details/80905631 对x1=x2(没有宽度)或者y1=y2(没有高度)的直线(line以及path ...
- python使用自带模块httplib进行http请求
#-*- encoding:utf-8 -*- import httplib, time class httpRequest(): def __init__(self, headers, reques ...
- MNIST机器学习入门(二)
在前一个博客中,我们已经对MNIST 数据集和TensorFlow 中MNIST 数据集的载入有了基本的了解.本节将真正以TensorFlow 为工具,写一个手写体数字识别程序,使用的机器学习方法是S ...
- [BZOJ3230]相似子串(后缀数组)
显然可以通过后缀数组快速找到询问的两个串分别是什么,然后正反各建一个后缀数组来求两个串的LCP和LCS即可. #include<cstdio> #include<cstring> ...
- oracle学习笔记(三)
索引: drop table test1 purge; drop table test2 purge; drop table test3 purge; drop table t purge; crea ...
- Go内存分配器可视化指南【译】【精】
当我第一次开始尝试理解 Go 语言的内存分配器时,整个过程让我抓狂.一切看起来都像一个神秘的黑盒子.因为几乎所有技术魔法(technical wizardry)都隐藏在抽象之下,所以你需要一层一层的剥 ...
- 【转载】C#中Convert.ToDouble方法将字符串转换为double类型
在C#编程过程中,可以使用Convert.ToDouble方法将字符串或者其他可转换为数字的对象变量转换为double类型,Convert.ToDouble方法有多个重载方法,最常使用的一个方法将字符 ...
- vue从零开始(三)指令
v-bind的使用 <!-- 绑定一个属性 --> <img v-bind:src="imageSrc"> <!-- 动态特性名 (2.6.0+) - ...