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 ...
随机推荐
- VUE 导出Excel(iframe)
1. 概述 1.1 说明 在开发过程中,有时候需要导出某数据表格(excel)以便客户使用,使用iframe对返回二进制文件进行下载处理.记录此功能,以便后期使用. 2. 示例 2.1 vue示例代码 ...
- Flutter终将逆袭!1.2版本发布,或将统一江湖
在去年 MWC 大展上发布首个 Beta 版后,Flutter 1.0 正式版于 2018 年 12 月召开的 Flutter Live 2018 上正式发布.今天在巴塞罗那召开的 MWC 发布会上, ...
- matplotlib 无法显示中文和负号的解决办法
matplotlib无法显示中文和负号解决办法
- C语言经典题目
回顾一下吧: 一. 有1.2.3.4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? 解析:可填在百位.十位.个位的数字都是1.2.3.4.组成所有的排列后再去 掉不满足条件的排列. 常规 ...
- 如何给PDF设置全屏动画
PPT文件可以播放全屏,并且可以实现飞入.分割.闪烁等动画模式播放.那么PDF文件可以吗?我们想要给PDF文件加入动画效果应该怎么做呢,也有很多的小伙伴不知道该怎么把PDF文件切换为全屏动画模式想要知 ...
- Excel-VBA入门(1): 基础 / 变量 /for / if/ 调试
(一) 启动VBA 打开excel ,选项-自定义功能区-开发工具, 在界面的开发工具下选择 宏安全: 勾选 启用所有 excel保存xlsm后缀的格式才可以用宏! 若启动VBA编辑器(以下简称VB ...
- EF 简单介绍<一>
一:EF概述 Entity Framework(EF)是一个开源的“对象/关系映射(ORM:Object Relational Mapping)”框架,使应用程序可以使用一种“纯”的对象模型来访问关系 ...
- 一致推崇的Linux系统还有那么安全吗?
今天想谈谈关于系统安全:我们都知道,Linux早已成为趋势,在我们互联网中占有不可或缺的地位,在我们眼中,它是神圣的,不可替代的,无懈可击的:真的是这样的吗? 但是关于病毒对Linux所造成的一系列威 ...
- Kubernetes 学习1 k8s架构概述
一.概述 1.意思:舵手,飞行员 2.特点 a.自动装箱,自我修复,水平扩展,服务发现和负载均衡,自动发布和回滚. b.密钥和配置管理,存储编排,批量处理执行. 二.架构术语 1.集群 master( ...
- 禁用大陆ip段
https://www.ip2location.com/free/visitor-blocker 有 .htaccess web.config等 以iis为例 打开C:\Windows\System3 ...