TZOJ 4493: Remove Digits
4493: Remove Digits 
总提交:
329
测试通过:77
描述
Given an N-digit number, you should remove K digits and make the new integer as large as possible.
输入
The first line has two integers N and K (1 ≤ K<N≤500000).
The next line has a N-digit number with no leading zero.
输出
Output the largest possible integers by removing K digits.
样例输入
4 2
2835
样例输出
85
#include <bits/stdc++.h>
using namespace std;
char s[];
int main()
{
ios::sync_with_stdio(false);
int n,k,num=;
char c;
s[]='';
cin>>n>>k;
for(int i=;i<n;i++){
cin>>c;
while(c>s[num]){
if(!k||!num) break;
num--,k--;
}
s[++num]=c;
}
if(k)
num=num-k;
s[++num]='\0';
cout << s+ << endl;
return ;
}
TZOJ 4493: Remove Digits的更多相关文章
- TOJ 4493 Remove Digits 贪心
4493: Remove Digits Description Given an N-digit number, you should remove K digits and make the new ...
- 【TOJ 4493】Remove Digits(单调栈贪心)
描述 Given an N-digit number, you should remove K digits and make the new integer as large as possible ...
- (Problem 37)Truncatable primes
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remo ...
- codeforces 887A Div. 64 思维 模拟
A. Div. 64 time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- kettle--组件(2)--计算器
组件如下: 对计算类型的说明如下: The table below contains descriptions associated with the calculator step: Functio ...
- Codeforces Round #444 (Div. 2)A. Div. 64【进制思维】
A. Div. 64 time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- Project Euler:Problem 37 Truncatable primes
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remo ...
- [LeetCode] Remove K Digits 去掉K位数字
Given a non-negative integer num represented as a string, remove k digits from the number so that th ...
- leetcode 402. Remove K Digits
Given a non-negative integer num represented as a string, remove k digits from the number so that th ...
随机推荐
- Sql Server 字符串操作总结
SQL Server 支持两种字符数据类型---常规和Unicode:常规类型包括char 和varchar:unicode包括nchar 和nvarchar.常规的每个字符占用一个字节存储,而uni ...
- ActiveMQ:使用Python访问ActiveMQ
Windows 10家庭中文版,Python 3.6.4,stomp.py 4.1.21 ActiveMQ支持Python访问,提供了基于STOMP协议(端口为61613)的库. ActiveMQ的官 ...
- 使用FLASK+winscp在服务器端发布一个表白网页
本地环境采用Windows 环境下Pycharm开发环境.
- Jmeter性能测试之进阶Java request的使用
在IDE中引用Jmeter的安装目录lib/ext中两个文件ApacheJMeter_core.jar和ApacheJMeter_java.jar Java request的类需要继承Abstract ...
- freemarker是什么东西?
前言 由于考虑到网站访问量,以及tocmat可能承受的最大访问压力,我们需要引进一些比较好的技术,来解决这个问题.所以在项目快要结束之际又收到消息,我们要考虑到这些问题然后对现在的项目进行改进,于是就 ...
- PHP中的面向对象思想
<?php header("Content-Type: text/html; charset=gb2312"); class person{ /** * 成员属性 * 在类中 ...
- 整理一下python中with的用法
ith替代了之前在python里使用try...finally来做清理工作的方法.基本形式如下: with expression [as variable]: with-block 当expressi ...
- contos最小包安装完后一些准备
yum upgradeyum install net-toolsyum -y install wgetyum -y install vim-enhanced yum install gcc gcc-c ...
- 《XXX重大技术需求征集系统》的可用性和可修改性战术分析
在网站的界面完整有效的呈现在最终用户面前前,其中经历的每一环节出现问题都会导致网站页面不可访问.原因如,如DNS被劫持.网站交换机失效,硬盘损坏,网卡松掉,机房停电等都可能导致网站不可用(网站故障)情 ...
- Android Studio 常用快捷键及常用设置
Android Studio 常用快捷键及常用设置 一.常用快捷键 快捷键 描述 Ctrl + Alt + L 格式化代码 Ctrl + ( +/- ) 展开/折叠 代码块 Ctrl + Shift ...