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. Spring线程安全的实现机制--ThreadLocal

    转载: http://blog.csdn.net/lufeng20/article/details/24314381

  2. 工作记录--使用FFmpeg将一个视频文件中音频合成到另一个视频中

    由于工作需要,临时被老大吩咐去研究一个FFmpeg工具,通过linux命令行去将一个视频中的音频提取出来并合成到另一个视频中,最终的效果是要保证2个视频中的音频都在一个视频中播放. 但是本人对FFmp ...

  3. 【洛谷】P1427 小鱼的猜数游戏

    P1427 小鱼的数字游戏 题目描述 小鱼最近被要求参加一个数字游戏,要求它把看到的一串数字(长度不一定,以0结束,最多不超过100个,数字不超过2^32-1),记住了然后反着念出来(表示结束的数字0 ...

  4. LUOGU P3112 [USACO14DEC]后卫马克Guard Mark

    题目描述 Farmer John and his herd are playing frisbee. Bessie throws the frisbee down the field, but it' ...

  5. Faster RCNN算法demo代码解析

    一. Faster-RCNN代码解释 先看看代码结构: Data: This directory holds (after you download them): Caffe models pre-t ...

  6. LINUX下C++编程如何获得某进程的ID

    #include <stdio.h> #include <stdlib.h> #include <unistd.h> using namespace std; pi ...

  7. token流程图

  8. FastAdmin 安装后点登录没有反应怎么办?

    FastAdmin 安装后点登录没有反应怎么办? 很多小伙伴安装后点"登录"没有反应. 这个 URL 是对的,但是页面就是不改变. 如果这时候点击 URL 变了,那没有到登陆界面, ...

  9. JQuery-- 获取元素的宽高、获取浏览器的宽高和垂直滚动距离

    * 能够使用jQuery设置尺寸 * .width() width * .innerWidth() width + padding * .outerWidth() width + padding + ...

  10. 【转载】【python】python练手项目

    入门篇 1.Python - Python 图片转字符画 50 行 Python 代码完成图片转字符画小工具. &lt;img src="https://pic3.zhimg.com ...