括号序列noip模拟赛
来源:互联网 发布:淘宝网京东商城童装 编辑:程序博客网 时间:2024/05/22 10:35
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
char s[maxn];
int n,m,l=0,r=0;
int main(){
scanf("%s",s+1);
int n=strlen(s+1);
for(int i=1;i<=n;i++){
if(s[i]=='('){
++l;
}
if(s[i]==')'){
if(l) --l;
else ++r;
}
}
cout<<r/2+r%2+l/2+l%2<<endl;
return 0;
}
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
char s[maxn];
int n,m,l=0,r=0;
int main(){
scanf("%s",s+1);
int n=strlen(s+1);
for(int i=1;i<=n;i++){
if(s[i]=='('){
++l;
}
if(s[i]==')'){
if(l) --l;
else ++r;
}
}
cout<<r/2+r%2+l/2+l%2<<endl;
return 0;
}
阅读全文
0 0
- 括号序列noip模拟赛
- NOIP模拟题 括号序列
- 【noip模拟赛】序列问题
- 【noip模拟赛】球的序列
- 【NOIP模拟】序列
- [NOIP模拟] 序列操作
- NOIP 模拟题 可接受序列
- noip模拟赛(10.4) 序列(sequence)
- 【NOIP 模拟赛】平均数 涂色游戏 序列题解
- NOIP模拟(11.02)T2 最佳序列
- 【NOIP模拟】 (11.2) T2最佳序列
- 【NOIP模拟】 (11.6) T2 序列操作
- NOIP模拟(11.06)T2 序列操作
- NOIP模拟 序列操作【线段树】
- NOIP模拟(20171102)T2 最佳序列
- noip模拟赛 双城记
- 【noip模拟赛】密码
- 10.10NOIP模拟赛
- 虚拟机如何安装linux
- 第三章 创建主窗口
- JS中setTimeout()的用法详解
- Android 百度地图 动态画多边形,并判断一个点是否在多边形内部
- Nexus 搭建maven 私有仓库
- 括号序列noip模拟赛
- 最全面的Js获取当前日期时间
- 日期格式化方法
- Linux监控工具介绍系列——smem
- python中计时工具timeit模块的基本用法
- 查询包含关系的SQL
- vimdiff比较两个文件
- Material Design 之 Touch Feedback
- Binary Exponential Backoff