4493: Remove Digits

时间限制(普通/Java):1000MS/3000MS     内存限制:65536KByte
总提交:
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的更多相关文章

  1. TOJ 4493 Remove Digits 贪心

    4493: Remove Digits Description Given an N-digit number, you should remove K digits and make the new ...

  2. 【TOJ 4493】Remove Digits(单调栈贪心)

    描述 Given an N-digit number, you should remove K digits and make the new integer as large as possible ...

  3. (Problem 37)Truncatable primes

    The number 3797 has an interesting property. Being prime itself, it is possible to continuously remo ...

  4. codeforces 887A Div. 64 思维 模拟

    A. Div. 64 time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  5. kettle--组件(2)--计算器

    组件如下: 对计算类型的说明如下: The table below contains descriptions associated with the calculator step: Functio ...

  6. 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 ...

  7. Project Euler:Problem 37 Truncatable primes

    The number 3797 has an interesting property. Being prime itself, it is possible to continuously remo ...

  8. [LeetCode] Remove K Digits 去掉K位数字

    Given a non-negative integer num represented as a string, remove k digits from the number so that th ...

  9. leetcode 402. Remove K Digits

    Given a non-negative integer num represented as a string, remove k digits from the number so that th ...

随机推荐

  1. 堆溢出学习笔记(linux)

    本文主要是linux下堆的数据结构及堆调试.堆溢出利用的一些基础知识 首先,linux下堆的数据结构如下 /* This struct declaration is misleading (but a ...

  2. EHCache:Eelment刷新后,timeToLiveSeconds失效了?

    个人以为只要设定了timeToLiveSeconds,中间过程不管有没有访问,只要LiveSeconds时间到了,缓存就会失效.但是开发时发现并非如此,经过一番折腾,最终发现自己的理解是正确的,还是使 ...

  3. Windows 下安装Git工具及基础使用

    Git简介 git是很好一个工具使用,可以执行liunx命令,有git环境后windows系统就可以进行shell命令操作,就可以添加其他liunx辅助软件进行执行,git也代码库管理工具,无论是上传 ...

  4. JavaScript入门学习笔记(二)

    JavaScript运算符: 算术运算符.赋值运算符和字符串连接运算符. 算法运算符与复制运算符用法参照Java: 字符串运算符: +运算符用于把文本值或字符串变量连接起来,适用于两个或更多字符串变量 ...

  5. Reveal 使用详解

    Reveal是一款调试iOS程序UI界面的神器 官网:https://revealapp.com 下载:https://revealapp.com/download/ 建议下载至少Reveal4版本, ...

  6. Java_数据类型

    变量就是申请内存来存储值. java的两大数据类型:内置数据类型和引用数据类型 数据类型 6种数据类型(4种整数型,2种浮点型),一种字符类型,一种布尔类型 数据类型 位数 描述 byte 8位 -1 ...

  7. Java+maven+httpcomponents封装post/get请求

    httpcore4.4.10, httpclient4.5.6 package com.test.http; import com.alibaba.fastjson.JSONArray; import ...

  8. ScheduledThreadPoolExecutor Usage

    refs: https://blog.csdn.net/wenzhi20102321/article/details/78681379 对比一下Timer和ScheduledThreadPoolExe ...

  9. [原创]FPGA JTAG工具设计(一)

    先来看不同JTAG方案,下载配置QSPI Flash所耗时间 基于FTDI方案,JTAG下载时间为494sec JTAG chain configuration ------------------- ...

  10. SpringBoot配置分析、获取到SpringBoot配置文件信息以及几种获取配置文件信息的方式

    Spring入门篇:https://www.cnblogs.com/biehongli/p/10170241.html SpringBoot的默认的配置文件application.properties ...