http://oj55.bianchengla.com/problem/169/

  还有这个,不怎么好做,最后用栈做出来了。

感觉比较有用的一个数据是:

10 3

1010101010

代码如下:

 #include <cstdio>
#include <iostream> using namespace std; const int N = ;
int n, k;
char s[N], stk[N], mx[N]; int main() {
while (~scanf("%d%d%s", &n, &k, s)) {
int top = -;
if (k == n - ) {
char mn = '';
for (int i = ; i < n; i++) mn = min(s[i], mn);
putchar(mn); puts("");
continue;
}
for (int i = ; i < n; i++) {
if (s[i] != '') while (~top && k >= top + && mx[top] > s[i]) top--, k--;
while (k && ~top && stk[top] > s[i]) {
if (s[i] == '' && top == ) break;
top--; k--;
}
stk[++top] = s[i];
if (top > ) mx[top] = max(s[i], mx[top - ]);
else mx[top] = s[i];
}
while (k--) top--;
//printf("top %d\n", top);
for (int i = ; i <= top; i++) putchar(stk[i]); puts("");
}
return ;
}

——written by Lyon

BUAA 169 电话费的更多相关文章

  1. openstack-kilo--issue(十一)Failed connect to 169.254.169.254:80; No route to host

    # curl http://169.254.169.254/latest/user-data curl: () Failed connect to ; No route to host 解决方案: c ...

  2. NEFU 169 步步惊心

    Description 马尔泰·若曦是康熙年间镇西大将军马尔泰的小女儿,自幼失母,却深得父亲姐姐宠爱,性格活泼任性.张晓,本是21世纪一都市白领,聪慧谨慎,玲珑剔透.因车祸而灵魂穿越到若曦身上,自此开 ...

  3. leetcode 169

    169. Majority Element Given an array of size n, find the majority element. The majority element is t ...

  4. BUAA & ICT 夏令营之旅

    我还只有二十几岁,总应该相信点什么吧. ================================ 7.10午后坐火车赶到北京.一路上火车行驶在茫茫云海里.车窗外的世界是这样子的:一片广袤的原野 ...

  5. BUAA 724 晴天小猪的神题(RMQ线段树)

    BUAA 724 晴天小猪的神题 题意:中文题,略 题目链接:http://acm.buaa.edu.cn/problem/724/ 思路:对于询问x,y是否在同一区间,可以转换成有没有存在一个区间它 ...

  6. 【openstack报错】【metadata问题】‘http://169.254.169.254/2009-04-04/meta-data/instance-id’ failed : url error [[Errno 111] Connection refused]

    [时间]2014年2月25日 [平台]ubuntu 12.04.3 openstack havana  with nova-network in multi-host [日志]实例启动时输出的日志内容 ...

  7. 169. Majority Element(C++)

    169. Majority Element Given an array of size n, find the majority element. The majority element is t ...

  8. instance 怎么获得自己的 Metadata - 每天5分钟玩转 OpenStack(169)

    要想从 nova-api-metadata 获得 metadata,需要指定 instance 的 id.但 instance 刚启动时无法知道自己的 id,所以 http 请求中不会有 instan ...

  9. 23. leetcode 169. Majority Element

    169. Majority Element Given an array of size n, find the majority element. The majority element is t ...

随机推荐

  1. JSP向后台传 递 参 数 的四种方式

    一.通过Form表单提交传值 客户端通过Form表单提交到服务器端,服务器端通过 Java代码 request.getParameter(String xx); 来取得参数(xx)为参数名称.通过ge ...

  2. 导入pymysql模块出错:No module named 'pymysql'

    前提: 使用的版本为:Python 3.6.4 pymysql已经被成功安装了,并通过命令行的方式验证已成功安装. 但在pycharm中运行工程时候时候报错:No module named 'pymy ...

  3. Hdu 1045 二分匹配

    题目链接 Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  4. Spring Boot → 11:项目实战-账单管理系统完整版

    Spring Boot → 11:项目实战-账单管理系统完整版

  5. objectarx之判断给定的三点是否共线

    bool ThreePointIsCollinear(const AcGePoint2d &pt1, const AcGePoint2d &pt2, const AcGePoint2d ...

  6. 【水滴石穿】RNNewsGo

    项目地址为:https://github.com/ImVeryGood/RNNewsGo 我们先来看一下页面 分析了一下项目,项目也是有用到redux-saga的 然后模块比较清晰 接下来我们分析代码 ...

  7. qt获取屏幕

    m_pDesktopWidget = QApplication::desktop(); // 屏体数量,包含扩展屏 int screenCount = m_pDesktopWidget->scr ...

  8. Mysql+php报错原因

    SQL syntax --语法错误,看near,错误会在near后引号中的内容 的附近 Table/Database....... dosen't existes ---表/库(库名/表名) 不存在 ...

  9. 介绍(javascript调试)

    Chrome developer tool Chrome浏览器得益于其优秀的V8解释器,javascript执行速度和内存占有率表现非常优秀.对于html+css+javascript前台技术的学习或 ...

  10. jq处理JSON数据, jq Manual (development version)

    jq 允许你直接在命令行下对 JSON 进行操作,包括分片.过滤.转换等等.让我们通过几个例子来说明 jq 的功能:一.输出格式化,漂亮的打印效果如果我们用文本编辑器打开 JSON,有时候可能看起来会 ...