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点,每次只能去 ...
随机推荐
- RWMutex:共享/专有的递归互斥锁
具有共享/独占访问权限,且具有升级/降级功能的互斥锁 介绍 我的目标是创建可以充当读/写锁定机制的对象.任何线程都可以锁定它以进行读取,但是只有一个线程可以锁定它以进行写入.在写入线程释放它之前,所有 ...
- 深度学习-生成对抗网络GAN笔记
生成对抗网络(GAN)由2个重要的部分构成: 生成器G(Generator):通过机器生成数据(大部分情况下是图像),目的是“骗过”判别器 判别器D(Discriminator):判断这张图像是真实的 ...
- How to do SSH Tunneling (Port Forwarding)
How to do SSH Tunneling (Port Forwarding) In this post we will see how ssh works?, what is SSH tunne ...
- Tensorflow在python3.7版本的运行
安装tensorflow pip install tensorflow==1.13.1 -i https://pypi.tuna.tsinghua.edu.cn/simple 可以在命令行 或者在py ...
- HDU2476 String painter(DP)
题目 String painter 给出两个字符串s1,s2.对于每次操作可以将 s1 串中的任意一个子段变成另一个字符.问最少需要多少步操作能将s1串变为s2串. 解析 太妙了这个题,mark一下. ...
- Python进阶(十三)----面向对象
Python进阶(十三)----面向对象 一丶面向过程编程vs函数式编程vs面向对象编程 面向过程: 简而言之,step by step 一步一步完成功能,就是分析出解决问题所需要的步骤,然后用函 ...
- sdcard不可执行.
Possibly you placed it on your sdcard -- which is mounted with the noexec flag. You either need to m ...
- Java visualvm
简介 VisualVM是一个集成多个JDK命令行工具的可视化工具.可以作为Java应用程序性能分析和运行监控的工具.开发人员可以利用它来监控.分 析线程信息,浏览内存堆数据.系统管理员可以利用它来监测 ...
- 基于xilinx Zynq UltraScale MPSoC平台的核心板及开发板介绍-米尔科技
近日,米尔科技推出国内首款基于xilinx Zynq UltraScale+MPSoC 平台的核心板及开发板.其优势主要有:采用16纳米制程,相比Znyq7000系列每瓦性能提升5倍,且单芯片融合4核 ...
- UAVCAN DSDL介绍
原文:http://uavcan.org/Specification/3._Data_structure_description_language/ DSDL:Data structure descr ...