发现codility上很难找到自己的代码,所以来存一下。

用的一种水法,不知道是结论对还是数据水。

处理出所有极大合法串最后就只剩)))((((状的括号,然后枚举右端点,左端点单调。

但是未匹配点数量为奇数时有点尴尬,我直接把答案减1水过去了,似乎总是能找到一个极大合法串中的括号修改后匹配多出来的这个括号?

#define MN 300001
int st[MN],top,mmh=,w[MN];
inline int max(int a,int b){return a>b?a:b;}
int solution(string &S, int K) {
top=;
int i;
for (i=;S[i];i++){
w[i]=S[i]==')';
if (top&&!w[st[top]]&&w[i]) top--;else st[++top]=i;
}
if (top==) return i;
int L=,a[]={,};st[]=-;st[top+]=i;
for (i=;i<=top;i++){
a[w[st[i]]]++;
while (((a[]+)/+(a[]+)/)>K&&L<i) a[w[st[++L]]]--;
mmh=max(st[i+]-st[L]--((a[]+a[])&),mmh);
}
return mmh;
}

Codility:Titanium 2016 challenge:BracketsRotation的更多相关文章

  1. [转]NLP Tasks

    Natural Language Processing Tasks and Selected References I've been working on several natural langu ...

  2. 2016.11.14 MIT challenge之课程总览

    Degree Chartshttp://catalog.mit.edu/degree-charts/computer-science-engineering-course-6-3/ MIT Chall ...

  3. 2016.10.08--Intel Code Challenge Final Round--D. Dense Subsequence

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  4. codechef May Challenge 2016 CHSC: Che and ig Soccer dfs处理

    Description All submissions for this problem are available. Read problems statements in Mandarin Chi ...

  5. codechef May Challenge 2016 FORESTGA: Forest Gathering 二分

    Description All submissions for this problem are available. Read problems statements in Mandarin Chi ...

  6. codechef May Challenge 2016 LADDU: Ladd 模拟

    All submissions for this problem are available. Read problems statements in Mandarin Chinese, Russia ...

  7. 深圳 Maker Faire 2016 & Microsoft Booth

    首先,感谢Hackster.io和微软,因为发表在Hackster.io的项目<A fall detection system based on Arduino, Windows and Azu ...

  8. (转) Summary of NIPS 2016

    转自:http://blog.evjang.com/2017/01/nips2016.html           Eric Jang Technology, A.I., Careers       ...

  9. python 2016 大会 pyconsk ppt ---python dtrace

    https://github.com/pyconsk/2016-slides PyCon SK 2016 - March 2016 1DTrace and PythonJesús Cea Aviónj ...

随机推荐

  1. IntelliJ IDEA(六) :Settings(下)

    一.Build,Execution,Deployment 项目的构建,执行,部署相关的配置. 1. Build Tools 构建工具,包含Maven,Gradle,Gant. Maven Work o ...

  2. UIImage类方法总结及UIImage生成方法对比

    http://mp.weixin.qq.com/s/A900w0Y5pGjuaB4j9Os9ww1.UIImage 生成方法的对比 Apple官方的文档为生成一个UIImage对象提供了两种方法: 1 ...

  3. C++ 头文件系列(iostream)

    1. 简介 这个头文件非常特殊,它只声明了8个常用流对象. 2. 8个对象 2.1 窄字符对象(char) extern istream cin extern ostream cout extern ...

  4. windows日志监控

    bat脚本,主要作用,每个五分钟读取日文本件中新增内容,进行错误赛选,如果有错误信息,将错误信息用邮件发送给管理员. 其中awk和sed需要手动下载 :读取number.txt文档,获取上一次执行时文 ...

  5. find 命令的误差估值与单位调整

    一.命令简介 find 命令的 -size 参数 单位b(不是byte而是block).c.w.k.M.G.默认是单位b ,也就是1block = 512byte = 0.5kb (文件系统ext4) ...

  6. MySQL 权限与用户表

    1.授权时创建用户 grant all privileges on *.* to zhengwenqiang@localhost identified by 'zhengwenqiang'; 2.收回 ...

  7. 初学者福音——10个最佳APP开发入门在线学习网站

    根据Payscale的调查显示,现在的APP开发人员的年薪达到:$66,851.这也是为什么那么多初学的开发都想跻身到APP开发这行业的主要原因之一.每当你打开App Store时候,看着琳琅满目的A ...

  8. Eclipse配置tomcat程序发布到哪里去了?

    今天帮同事调一个问题,明明可以main函数执行的,他非要固执的使用tomcat执行,依他.但是发布到tomcat之后我想去看看发布后的目录,所以就打开了tomcat中的webapps目录,可是并没有发 ...

  9. 冲顶大会APP技术选型及架构设计

    我在1月4日看到虎嗅推送"王思聪撒币"的消息,然后开始推敲背后技术.其中涉及直播流.实时弹幕.OAuth2.0开放授权.SMS api.Push网关.支付接口等业务,其技术实现并不 ...

  10. windows 下运行angualr/material2 项目

    第一步:到github上clone  angular/material2 项目 第二步:npm install 第三步: 打开git bash (cmd 或 powershell 是无法成功运行该项目 ...